动态添加点击事件的实现
2017-05-12 本文已影响0人
Liuqhahah
public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener
{
protected void addClick(intid)
{
View view =mVFinder.findView(id);
addClick(view);
}
}
public class ViewFinder{
private SparseArray mViews;
publicTfindView(int viewId)
{
View view =mViews.get(viewId);
if(view ==null)
{
view =mLayout.findViewById(viewId);
mViews.put(viewId,view);
}
return(T) view;
}
}