私はブラジル出身で、ボタンの画像とテキストを含むリストビューがあります。ボタンのリストビューをクリックして、クリックしている行の原因となるビューを取得しようとしています。だから私はこれが私のボタンである行に変更を加えることができます。
何が起こっているのか、そして以下のコードの場合、ボタンをクリックすると、どのボタンのリストでも、彼は常に最初のリスト項目で変更を行い、私は彼にそれぞれの行で変更を加えてもらいたいと思いました。したがって、このリスト
画像---------------------------テキスト-ボタン
画像----------------- ----------テキスト-ボタン
の画像---------------------------テキスト-ボタン
の画像--- ----------------------テキスト-ボタン
ボタンをクリックすると、彼は行の例のテキストを変更するだけです。
画像---------------------------テキスト-ボタン
画像----------------- ---------変更-ボタン<-クリックされた画像
---------------------------テキスト-ボタンの
画像------------ --------------- TEXT--BUTTON
と..
画像---------------------------テキスト-ボタン
画像----------------- ----------テキスト-ボタン
の画像---------------------------テキスト-ボタン
の画像--- ------------------------変更-ボタン<-クリック
それを思い出して、フラグメントリスト内のアダプタを使用しました申し訳ありませんが、私の英語は悪いです!
public class JAdapterList extends BaseAdapter implements OnClickListener {
private LayoutInflater mInflater;
private ArrayList<JItemList> itens;
public JAdapterList(Context context, ArrayList<JItemList> itens) {
//Itens que preencheram o listview
this.itens = itens;
//responsavel por pegar o Layout do item.
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return itens.size();
}
public JItemList getItem(int position) {
return itens.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View view, ViewGroup parent) {
//Pega o item de acordo com a posção.
JItemList item = itens.get(position);
//infla o layout para podermos preencher os dados
view = mInflater.inflate(R.layout.navlistitem, null);
((TextView) view.findViewById(R.id.textListView)).setText(item.getNome());
ImageButton ib = (ImageButton) view.findViewById(R.id.imageButton1);
ib.setOnClickListener(this);
return view;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
View vv = v.getRootView();
ImageView tv = (ImageView) vv.findViewById(R.id.imageView1);
TextView texto = (TextView) vv.findViewById(R.id.textListView4);
texto.setText("CHANGE");
tv.setAnimation(AnimationUtils.loadAnimation(tv.getContext(), R.anim.motion));
}
}