djItu
djItu

Reputation: 39

display on a listview

This is an Intent from another class, The name product contains data from sqlite database.

my problem is i want to display the information on the ListView but i do not know how to do it.

Intent updateCustomerIntent = getIntent();
         String product = updateCustomerIntent.getStringExtra("product");
         Log.d("checking........", product);

i have tried this

ListView listView = (ListView) findViewById(R.id.mylist);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
  android.R.layout.simple_list_item_1, android.R.id.text1, product);

listView.setAdapter(adapter); 

but it gives me errors

I will appriciate your help.

Upvotes: 1

Views: 60

Answers (1)

hardartcore
hardartcore

Reputation: 17047

Make it like this :

String[] values = new String[] { product };

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
  android.R.layout.simple_list_item_1, android.R.id.text1, values);

Upvotes: 1

Related Questions