我的ExpandableListView有一些EditText框和按鈕(它是一個登錄/註冊屏幕)。 我想用一個開關盒的onClick函數來選擇已被點擊的按鈕並對它們做些什麼。ExpandableListView中按鈕的onClick方法
對於按鈕,我無法設置onClickListener。
所有這些都在我寫的Custom Expandable List Adapter Class中。
我知道有另一種方法來解決自定義可擴展列表適配器中的正常功能,但我不知道如何。
這裏的代碼片段相關WITHIN CustomExpandableAdapter類:
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
v = null;
position = 0;
position=getChildId(groupPosition, childPosition);
* - - unrelated code - *
if(position==2) //Draws Forgot Button
{
v = inflater.inflate(R.layout.forgot, parent, false);
View forgot = v.findViewById(R.id.fpb);
//What goes here to setOnClickListener?
}
return v;
}
public void onClick(View w) {
PopupWindow pw= new PopupWindow(inflater.inflate(R.layout.popup_layout, null, false),220,160, true);;
switch(w.getId())
{
case R.id.fpb:
{
pw.showAtLocation(v, Gravity.CENTER, 0, 0);
}
}
有人能隨心所欲助陣?
我重新做了整個公司德和它的工作。 最終的解決方案是使用 setOnClickListener(this);只是由於某種原因以前沒有工作。雖然謝謝! – Karan 2012-07-18 19:04:41