Hi,
my problem is that I have data in arraylist and I cant get it to
adapter.
I created this adaper in separate class:
public class MyAdapter extends ArrayAdapter<MyRecord>{
private ArrayList<MyRecord> al;
private LayoutInflater inflater;
public MyAdapter(Context context,int resources, int
textViewResourceId, ArrayList<MyRecord> al) {
super(context,resources, textViewResourceId);
this.inflater = LayoutInflater.from(context);
this.al=al;
}
public View getView(int position, View convertView,ViewGroup parent)
{
View row = convertView;
if(row==null){
row = inflater.inflate(R.layout.list, parent, false);
}
TextView spot=(TextView)row.findViewById(R.id.TextView01);
TextView datu=(TextView)row.findViewById(R.id.TextView02);
spot.setText(Double.toString(al.get(position).spotreba));
datu.setText(al.get(position).date);
return row;
}
}
I create adapter in MainActivity like this:
ArrayList<MyRecord> al - here I have all my data. and this is field
of MainActivity extends Activity
ListView lv = (ListView) findViewById(R.id.listik);
adapter = new MyAdapter(this,R.id.listik,R.layout.list,al);
lv.setAdapter(adapter);
when I do this nothing happens. ListView is empty.
in method onCreate I setContentView from resource this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/ll">
<ListView
android:id="@+id/listik"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fastScrollEnabled="true"
android:smoothScrollbar="true"
android:scrollbars="vertical"
android:scrollbarSize="10sp">
</ListView>
</LinearLayout>
Aplication run corectly data are alright but I cant display them to
the ListView. please help me find what I do wrong. And I can't find
bug, I have tried a lof of options but nothing helps me.
thank you very much.
Richard Sámela
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en