使用按钮保存EditText以便稍后调用

时间:2016-07-26 01:34:19

标签: android

我有ListView ImagebuttonsEditText。如何按下按钮,它可以保存按钮行上的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);

        }
    });
}

1 个答案:

答案 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");

        }
    });
}