2
我設置了一個按鈕,在佈局不可見的,現在我需要將其放置在列表項的長按..如何設置陣列中的適配器
我看到長按一個按鈕的可見性創建了一個類擴展數組適配器,並且我聲明瞭這個類中的按鈕.. 現在我需要在代碼中長按列表項來訪問此按鈕以將其設置爲可見。 我如何訪問此按鈕setOnItemLongClickListener
..
而且應用力宣佈在arrayadapter按鈕時關閉..
這裏是我的代碼..
lv.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//arg1.findViewById(R.id.btndelete).setVisibility(View.VISIBLE);
Toast.makeText(getApplicationContext(), "long press", Toast.LENGTH_LONG).show();
return false;
}
});
class myAdapter extends ArrayAdapter<String>
{
Button btndlt;
View row;
public myAdapter(Context context,ArrayList<String> objects)
{
super(context, android.R.layout.simple_list_item_1, objects);
}
public View getView(final int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater=getLayoutInflater();
row = inflater.inflate(R.layout.list_item, parent, false);
btndlt = (Button) row.findViewById(R.id.btndelete);
}
}
嘗試在適配器類中設置視圖的'onitemlongclickListener'。並且,在那裏提高知名度。我不確定,這是否正確。 – Praveenkumar
我想你有你的答案[這裏](http://stackoverflow.com/q/12136520/792232) – Abhi
@Abhi:不,我沒有得到答案.. – Deepzz