vendredi 26 août 2016

use if-statement to recognize arraylist data in android

i want to use condition " if " for my array list

here is my code in (activity 1) to send string in textview with button to static variable that is in (exchange activity) :

    Button btn1 = (Button) findViewById(R.id.btn1);
    final TextView text = (TextView) findViewById(R.id.txt1);

    btn1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            exchange.in =text.getText().toString();

        }
    });

here is my static variable in (exchange activity)

public static String in;

and here is my (activity 2) code that i use array list in it to receive & store string from (activity 1) that is in static variable (exchange.in)

    ListView list;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ArrayList<String> web = new ArrayList<String>(10);
        for (int i = 0; i < 10; i++) {
            web.add("");
        }

        CustomList adapter = new
        CustomList(activity_main.this, web);
        list = (ListView) findViewById(R.id.list);
        list.setAdapter(adapter);


    }

now i don't know how to store data from (exchange.in) to arraylist and then use if condition to recognize that, if arraylist(0) was full, put data that is in (exchange.in) to arraylist(1) and it will continue like this...

is anyone know about this?

Aucun commentaire:

Enregistrer un commentaire