Calling Adaptor Class to fill listview
DB db_obj= new DB();
db_obj.open();
result1=db_obj.getUserData("select * from tbl_name");
db_obj.close();
historyclass obj_historyclass = new historyclass();
lv_history.setAdapter(obj_historyclass);
Adaptor Class
public class historyclass extends BaseAdapter{
@Override
public int getCount() {
int count=result1.size();
return count;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View oldview, ViewGroup arg2) {
View currentview;
if(oldview== null)
{
LayoutInflater le= getLayoutInflater();
currentview=le.inflate(R.layout.lv_his, null);
}
else
{
currentview=oldview;
}
final TextView c_colum_one = (TextView)currentview.findViewById(R.id.c_colum_one);
final TextView c_colum_two = (TextView)currentview.findViewById(R.id.c_colum_two);
final TextView c_colum_three= (TextView)currentview.findViewById(R.id.c_colum_two);
c_colum_one.setText(result1.get(position)[0]);
c_colum_two.setText(result1.get(position)[1]);
c_colum_three.setText(result1.get(position)[2]);
return currentview;
}
}
No comments:
Post a Comment