Hi i have a slight problem when using an ArrayAdapter, what is happening is that not all of each rows data is being displaying in each row but for other rows its fine and displaying all the data, i hope that makes sense. example list result as displayed in app.
20238 Christian Neza
20394 Christian Kezama
23554 Christian
In the above list displayed in the app the only one showing all of the row text is the middle one 20394.
In the below code for the ClientListAdapter i have put a Log if the record = 20238, the output from that log shows that the actual row data is
20238 Christian Neza Bizimana
and also 23554 has cut of the last part of the text to be displayed, very odd saying 50% of the list is displaying correct.
public class ClientListAdapter extends ArrayAdapter<ClientListVO> {
private ArrayList<ClientListVO> items;
public ClientListAdapter(Context context, int textViewResourceId, ArrayList<ClientListVO> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.renderer_clientlist, null);
}
ClientListVO o = items.get(position);
if (o != null) {
if(o._id == 20238)
Log.i("ClientListAdapter", o.toString());
TextView tt = (TextView) v.findViewById(R.id.toptext);
if (tt != null)
tt.setText(o.toString());
}
return v;
}
}
The R.layout.renderer_clientlist
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:orientation="vertical" >
<TextView
android:id="@+id/toptext"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center_vertical" />
</LinearLayout>
The final piece of code i think you need is the actual ListView in the Activity where the data is being displayed.
<ListView
android:id="@+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Please can anyone shed any light on what im doing wrong, Thanks in Advance I'm on a really tight deadline for this.