我有ListView
Imagebuttons
和EditText
。如何按下按钮,它可以保存按钮行上的EditText
我在onClick
中创建了什么代码?
public View getView(int position, View convertView, ViewGroup parent) {
View linha = mInflater.inflate(R.layout.suport_activity, parent, false);
ImageButton ib = (ImageButton) convertView.findViewById(R.id.image_adicionar);
ib.setImageDrawable(getResources().getDrawable(R.drawable.add_car));
ImageButton carrinhoButton = (ImageButton) linha.findViewById(R.id.image_adicionar);
carrinhoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.class, CarrinhoActivity.class);
}
});
}
答案 0 :(得分:-2)
public IssoActivity {
ImageButton ib;
ImageButton carrinhoButton;
boolean ib;
boolean carrinhoButton;
EditText issoText;
public View getView(int position, View convertView, ViewGroup parent) {
View linha = mInflater.inflate(R.layout.suport_activity, parent, false);
ib = (ImageButton) convertView.findViewById(R.id.image_adicionar);
ib.setImageDrawable(getResources().getDrawable(R.drawable.add_car));
carrinhoButton = (ImageButton) linha.findViewById(R.id.image_adicionar);
carrinhoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.class, CarrinhoActivity.class);
if (ib)
IssoActivity.issoText.setText("Clicked IB");
if (carinhoButton)
IssoActivity.issoText.setText("Clicked Carinho Button");
}
});
}