1
解僱我創造了我自己的按鈕的OnClick不會在自定義按鈕,但在父類
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
...></ImageView>
<ImageView
...></ImageView>
<TextView
...></TextView>
</merge>
她是班級爲我的按鈕
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");
}
的的onClick功能不起作用。但它的作品,如果我把我的活動按鈕重寫onClick函數。
是否有解決方案在我的StandardButton類中單擊按鈕時觸發函數。這個類應該知道它是否被點擊,而不是活動!
這可能有助於瞭解你想要什麼實現或者更直接的,爲什麼常規的Android按鈕實現不能滿足你的需求。實驗/學習是一個完全可以接受的答案。 :) – 2011-04-21 15:22:24
你可以很容易地看到好處。標準Button沒有2 Imageview和1 Textview。 – passsy 2011-04-23 08:33:41