平时遇到的问题

Toolbar的使用

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_evidence);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeAsUpIndicator(R.drawable.icon_back_gary);

加入阴影效果
android:elevation="6dp"

onItemLongClick返回值作用

  • true if the callback consumed the long click, false otherwise.
    返回true的话只响应长按事件,返回false反之
    即返回false的话机会响应长按也会响应点击事件

LayoutInflate.inflate()方法

作用:动态加载视图

常用的两种调用方式:
public View inflate(int resource, ViewGroup root)
public View inflate(int resource, ViewGroup root, boolean attachToRoot)
参数介绍:
1.resource 布局的资源id
2.root 填充的父视图
3.attachToRoot 是否将载入的视图绑定到根视图中

(attachToRoot传true时会报重复绑定的错误)

inflate(R.layout.item, null)和inflate(R.layout.item, parent,false)的区别
前者添加到父布局的时候会忽略掉R.layout.item中对于父视图的layout_xx的属性,推荐使用后面这种写法。

你可能感兴趣的:(平时遇到的问题)