0

I'm writing an android application which starts of as a listview, for which I've written a class that extends ArrayAdapter, populating each row from a database. When an Item in the list is clicked, it fires an intent to another class which I want to list the details of the item clicked, so I can inflate the view with the item details. For now I just want to inflate one TextView as follows.

<TextView 
    android:id="@+id/name"
    android:textColor="#FFFFFF"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
/>

How would I go about writing the class for a details page which only establishes itself after receiving an intent? Do I need to extend something to override the getView method?

Chironex
  • 809
  • 3
  • 10
  • 28

3 Answers3

2

For inflating you can use

public View myView()
{
    View v;
    LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    v = inflater.inflate(R.layout.prob3_layout, null);
    return v;
}
Arun Badole
  • 10,977
  • 19
  • 67
  • 96
0

You need to create Custom Adapter to show your Values in List View. Check out this Custom List in Android

Let me know if you find any difficulty.

Community
  • 1
  • 1
Venky
  • 11,049
  • 5
  • 49
  • 66
0

Generally what you want to do is write another Activity (a details Activity). You will have a corresponding view (XML) to go with this activity. You pass the id of the item clicked through a Bundle. Here is another question which shows hows to pass data to another Activity (through an Intent).

So you would build a new view to show the details. In your new DetailsActivity.java that extends Activity, in your onCreate you would call setContent(R.layout.detailsView) - where R.layout.detailsView corresponds to an xml you created.

Community
  • 1
  • 1
Jack
  • 9,156
  • 4
  • 50
  • 75