I need to have a listview like it is having for the following android application
Since I cannot post the image this is how it should be
INAGE Over here | Some Free text | User name etc
Here is your task
Task 1 >
Task 2 >
Task 1 & Task 2 are the list which would be dynamically picked up from the DB
I am trying to have a list with a textview the problem is that I can only get the List or the text view not both any point of time I have even tried relative layout in that case i see the text overlapping
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/g_tracker_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/question1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoLink="all"
android:text="@string/question1"
/>
<ListView android:id="@+id/ListView01"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Any help guidance would be really helpful in achiving the layout similar to this
Following is the snippet in the onCreateMethod()
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.g_tracker_home);
this.dh = new TrackerDAO(this);
lv1=(ListView)findViewById(R.id.ListView01);
trackerObj = dh.selectAll();
if(trackerObj!=null) {
List<String> al = new ArrayList<String>();
for(Tracker obj : trackerObj ){
al.add(obj.getTrackerName());
}
lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , al));
}
Try something like this:
That's really nice. After you get some expertise, you will see that
RelativeLayout
is one of the best layout schemes. In this simple case you could useLinearLayout
too, but when things start getting complex, it's better to useRelativeLayout
which is really flexible and will allow you to reduce the need of nest elements.Here is an excerpt from one of my books showing how to take control over the creation of list rows, so you can mix text and images. The sample projects described in that excerpt can be found in this directory of the book's GitHub repository.
In a nutshell, for an
ArrayAdapter
, you will need to subclass it and overridegetView()
to update both the text and the image.