pas*_*ssy 1 android onclick button parent-child
我创建了自己的按钮
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
...></ImageView>
<ImageView
...></ImageView>
<TextView
...></TextView>
</merge>
Run Code Online (Sandbox Code Playgroud)
她是我的Button的班级
public class StandardButton extends RelativeLayout implements OnClickListener{
...
private void init(Context context){
this.setClickable(true);
this.setEnabled(true);
this.setFocusable(true);
this.setFocusableInTouchMode(true);
LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.standard_button, this);
}
@Override
public void onClick(View v) {
setLabel("Click");
}
Run Code Online (Sandbox Code Playgroud)
onClick函数不起作用.但是如果我把Button放在我的Activity中,它会覆盖onClick函数.
在我的StandardButton类中单击Button时是否有触发函数的解决方案.这个班级应该知道它是否被点击,而不是活动!
| 归档时间: |
|
| 查看次数: |
1238 次 |
| 最近记录: |