私は3つのフィールドと1つのチェックボックスを持つクラスの配列アダプタを持っています 私は各textView上でイベントをクリックshwしたいです、私のコードは、このクラスでクリックイベントを発生させる方法。私は混乱していますアダプタのイベントをクリックしてくださいandroid
public class ItemReportAdapter extends ArrayAdapter<SalesForce>{
private LayoutInflater li;
public ItemReportAdapter(Context context,List<SalesForce> items){
super(context,0,items);
li=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position,View convertView,ViewGroup parent){
final SalesForce item=getItem(position);
View v=convertView;
if(v==null){
v=li.inflate(R.layout.sfreportview,null);
}
final TextView idView=(TextView)v.findViewById(R.id.itemID);
if(idView!=null){
idView.setText(""+item.getUserID());
}
idView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
popup();
}
private void popup() {
//what to write in here so as i can be shifted to other drill down
}
});
final TextView captionView=(TextView)v.findViewById(R.id.itemCaption);
if(captionView!=null){
captionView.setText(item.getName());
}
final TextView typeView=(TextView)v.findViewById(R.id.itemType);
if(typeView!=null){
typeView.setText(item.getUserType());
}
final CheckBox chkbox=(CheckBox)v.findViewById(R.id.checkboxes);
chkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
popup();
}
private void popup() {
// TODO Auto-generated method stub
}
});
return v;
}
public long getItemId(int position){
return getItem(position).getUserID();
}
public boolean hasStableIds(){
return true;
}
私はそれをどうすればいいのですか? 何か助けていただければ幸いです!1:
idViewのクリックイベントが既にあるようですね。 – kosa
'idView.setOnClickListener(新しいOnClickListener()'はあなたのクリックリスナーではありませんか?おそらくあなたはあなたの質問を既に聞いているように聞こえるので、あなたの質問を言い換えることができます。 –
ManishGuptaこれはクリックリスナーですが、たくはそれを行うために私を禁止意図を使用して次の授業に行くので idView.setOnClickListener(新OnClickListener(){ @Override ます。public void onClickの(ビューV){ ポップアップ(); } ます。private voidポップアップ() { 次のクラスファイルに転送できるようにここに書き込むもの } }); –