I have one listview and adapter ImageButton for delete data, but I don't know how to delete data by setOnClick. I need to click ImageButton and delete data. I have data type room not null.
public class OrgManageRoom extends AppCompatActivity {
private ListView listView;
private ArrayAdapter<String> arrayAdapter;
private ArrayList<String> list_of_rooms = new ArrayList<>();
ArrayList<HashMap<String, String>> MyArrList;
public ArrayList<String> arr;
public ArrayAdapter adapter;
private DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference().getRoot();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_org_manage_room);
// listView = (ListView)findViewById(R.id.listView);
// listView.setAdapter(new ImageAdapter(this));
// arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,list_of_rooms);
// listView.setAdapter(arrayAdapter);
createAdapter();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(OrgManageRoom.this,OrgAddUser.class);
startActivity(i);
}
});
}
private void createAdapter() {
listView = (ListView)findViewById(R.id.listView);
listView.setAdapter(new ImageAdapter(this));
mDatabase = FirebaseDatabase.getInstance().getReference().child("AllRoom");
mDatabase.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
Set<String> set = new HashSet<String>();
Iterator i = dataSnapshot.getChildren().iterator();
while (i.hasNext()){
set.add(((DataSnapshot)i.next()).getKey());
}
list_of_rooms.clear();
list_of_rooms.addAll(set);
// arrayAdapter.notifyDataSetChanged();
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
public class ImageAdapter extends BaseAdapter {
private Context context;
public ImageAdapter(Context c) {
// TODO Auto-generated method stub
context = c;
}
public int getCount() {
// TODO Auto-generated method stub
return list_of_rooms.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = inflater.inflate(R.layout.deleteroom, null);
}
// ColImgID
TextView txtPosition = (TextView) convertView.findViewById(R.id.ColImgDesc);
txtPosition.setPadding(10, 0, 0, 0);
txtPosition.setText(list_of_rooms.get(position));
ImageButton cmdShared = (ImageButton) convertView.findViewById(R.id.imgCmdShared);
cmdShared.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(OrgManageRoom.this, "test" + list_of_rooms.get(position), Toast.LENGTH_LONG).show();
}
});
return convertView;
}
}
}
Sorry, I edit all code and I make project chat firebase and show listview listroom for add user and delete user and manageroom. It deletes room edit nameroom. Same I need to click imagebutton for delete listroom.
Related
Good day
i am having problem when I am trying to delete my item from my sqlite.
it doesn't update my listview.
MAIN ACTIVITY
this is my main activity, both onCreate and onResume
private CustomAdapter customAdapter;
#Override
protected voidonCreate(Bundle savedInstanceState) {
lv = (ListView)findViewById(R.id.memo_list_view);
customAdapter = new CustomAdapter(this, memoIDS, memoTitles, memoCreatedDates, memoAlarmedDates);
}
#Override
protected voidonResume() {
memoIDS.clear();
memoTitles.clear();
memoCreatedDates.clear();
memoAlarmedDates.clear();
Cursor c=SplashActivity.db.rawQuery("SELECT * FROM memos", null);
if(c.getCount()!=0) {
while(c.moveToNext()) {
memoIDS.add(c.getString(0));
memoTitles.add(c.getString(1));
memoCreatedDates.add(c.getString(3));
memoAlarmedDates.add(c.getString(4));
}
c.close();
lv.setAdapter(customAdapter);
}
}
CustomAdapter
from this customadater, i am trying to delete the record i created.
public class CustomAdapter extends BaseAdapter{
List<String> mMemoIds;
List<String> mMemoTitle;
List<String> mMemoCreatedDate;
List<String> mMemoAlarmedDate;
Context context;
private static LayoutInflater inflater=null;
public CustomAdapter(MemoListActivity mainActivity, List<String> memoIds, List<String> memoTitle, List<String> memoCreatedDate, List<String> memoAlarmedDate) {
mMemoIds = memoIds;
mMemoTitle = memoTitle;
mMemoCreatedDate = memoCreatedDate;
mMemoAlarmedDate = memoAlarmedDate;
context = mainActivity;
inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return mMemoIds.size();
}
#Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public class Holder
{
TextView tViewMemoTitle;
TextView tViewMemoCreatedDate;
TextView tViewMemoAlarmedDate;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
Holder holder=new Holder();
View rowView;
rowView = inflater.inflate(R.layout.program_list, null);
holder.tViewMemoTitle=(TextView) rowView.findViewById(R.id.memo_list_title);
holder.tViewMemoCreatedDate=(TextView) rowView.findViewById(R.id.memo_list_created_date);
holder.tViewMemoAlarmedDate=(TextView) rowView.findViewById(R.id.memo_list_alarmed_date);
holder.tViewMemoTitle.setText(mMemoTitle.get(position));
holder.tViewMemoCreatedDate.setText("Created Date : " + mMemoCreatedDate.get(position));
holder.tViewMemoAlarmedDate.setText("Alarm Date : " + mMemoAlarmedDate.get(position));
rowView.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Cursor c=SplashActivity.db.rawQuery("SELECT * FROM memos WHERE id='"+mMemoIds.get(position)+"'", null);
if(c.moveToFirst())
{
SplashActivity.db.execSQL("DELETE FROM memos WHERE id='"+mMemoIds.get(position)+"'");
notifyDataSetChanged();
}
}
});
return rowView;
}
}
my problem is, i don't know where to put
notifydatasetchanged();
rowView.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Cursor c=SplashActivity.db.rawQuery("SELECT * FROM memos WHERE id='"+mMemoIds.get(position)+"'", null);
if(c.moveToFirst())
{
SplashActivity.db.execSQL("DELETE FROM memos WHERE id='"+mMemoIds.get(position)+"'");
mMemoIds.remove(c.getString(0));
mMemoTitle.remove(c.getString(1));
mMemoCreatedDate.remove(c.getString(3));
mMemoAlarmedDate.remove(c.getString(4));
notifyDataSetChanged(); // Insert your notifydatasetchanged here
}
}
});
This is my custom list adapter. I want to update the values in table using the update ImageButton in the list. On clicking it, the old values should be shown in a new activity and then the edited value must be stored in the database. However, I am unable to pass an intent inside the onClick() method.
Please suggest me a solution
public class CustomListAdapter extends BaseAdapter implements ListAdapter
{
private ArrayList<String> list = new ArrayList<String>();
private Context context;
OnItemSelectedListener onItemSelectedListener;
public int pos;
String pass,pass2,edit,epass;
public CustomListAdapter(List list, Context context) {
this.list = (ArrayList<String>) list;
this.context = context;
}
#Override
public int getCount() {
return list.size();
}
#Override
public Object getItem(int pos) {
//pass2 = list.toString();
return list.get(pos);
}
//#Override
//public Long getItemId(int pos) {
//
// //just return 0 if your list items do not have an Id variable.
//}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.layout_custom_list, null);
}
//Handle TextView and display string from your list
final TextView listItemText = (TextView)view.findViewById(R.id.list_item_string);
listItemText.setText(list.get(position));
//Handle buttons and add onClickListeners
ImageButton deleteBtn = (ImageButton)view.findViewById(R.id.delete_btn);
ImageButton editBtn = (ImageButton)view.findViewById(R.id.edit_btn);
//Button addBtn = (Button)view.findViewById(R.id.add_btn);
deleteBtn.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v) {
//do something
list.remove(position);
pass = listItemText.getText().toString();
notifyDataSetChanged();
pass2 = pass.substring(0,pass.indexOf(' '));
System.out.println(pass2);
Moneydb.delete(pass2);
}
});
editBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v2) {
// TODO Auto-generated method stub
edit=listItemText.getText().toString();
epass = listItemText.getText().toString();
edit = epass.substring(0,epass.indexOf(' '));
Moneydb.edit(edit);
}
});
return view;
}
protected Context getContext() {
// TODO Auto-generated method stub
return null;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
//return list.get(position).getId();
return 0;
}
public void clear() {
//CustomListAdapter collection = null;
// TODO Auto-generated method stub
list.clear();
notifyDataSetChanged();
}
I suggest you to assign and ContextMenu to your list view with two MenuItem, Edit and Delete and write associated code outside of adapter
or you can start Activity by :
Intent new_intent = new Intent(v.getRootView().getContext(),edit_activity.class);
new_intent.putExtra("Key","Value");
v.getRootView().getContext().startActivity(new_intent);
i think the first method is best ;)
I create a listview get all contact from address book of Android. I try to update listview by onResume() but It's not working.
Here is my code:
public class Display extends Activity implements OnItemClickListener{
List<String> name1 = new ArrayList<String>();
List<String> phno1 = new ArrayList<String>();
List<String> email1 = new ArrayList<String>();
MyAdapter ma ;
ListView lv;
int countContact;
TextView textViewManyCount;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.display);
getAllContacts(this.getContentResolver());
lv= (ListView) findViewById(R.id.lv);
ma = new MyAdapter();
lv.setAdapter(ma);
lv.setOnItemClickListener(this);
lv.setItemsCanFocus(false);
lv.setTextFilterEnabled(true);
textViewManyCount = (TextView) findViewById(R.id.textViewManyCount);
}
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
}
public void getAllContacts(ContentResolver cr) {
Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC");
countContact = phones.getCount();
while (phones.moveToNext())
{
String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
String email = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
System.out.println(".................."+phoneNumber);
name1.add(name);
phno1.add(phoneNumber);
email1.add(email);
}
phones.close();
}
class MyAdapter extends BaseAdapter implements CompoundButton.OnCheckedChangeListener
{ private SparseBooleanArray mCheckStates;
LayoutInflater mInflater;
TextView textViewName,textViewPhone,textViewEmail;
MyAdapter()
{
mCheckStates = new SparseBooleanArray(name1.size());
mInflater = (LayoutInflater)Display.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return name1.size();
}
#Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi=convertView;
if(convertView==null)
vi = mInflater.inflate(R.layout.list_user, null);
textViewName = (TextView) vi.findViewById(R.id.textViewName);
textViewPhone = (TextView) vi.findViewById(R.id.textViewPhone);
textViewEmail = (TextView) vi.findViewById(R.id.textViewEmail);
textViewName.setText("Name :"+ name1.get(position));
textViewPhone.setText("Phone No :"+ phno1.get(position));
textViewEmail.setText("Email :"+ email1.get(position));
textViewManyCount.setText("Contacts: "+countContact);
return vi;
}
#Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
}
}
When I running app, It's load all contact but when I click button Home and change some information in Address book then click icon app to open app again. And onResume() method not working.
Here my onResume()
#Override
protected void onResume()
{
super.onResume();
if (lv != null)
{
updateData();
}
}
private void updateData()
{
getAllContacts(this.getContentResolver());
ma = new MyAdapter();
lv.setAdapter(ma);
ma.notifyDataSetChanged();
}
So some body help me! Plz!
Try by Replacing your updateData():
private void updateData()
{
getAllContacts(this.getContentResolver());
ma.notifyDataSetChanged();
}
You may be referencing an old ListView (lv) that is not the new ListView you see when you resume your Activity. Try getting the reference to lv again using Activity.findViewById(R.id.xxxx) in onResume().
You could also try reusing the old adapter instead of creating a brand new one (by clearing it and updating it's content). If you're reusing the old adapter, just make sure you give the old adapter to the new ListView using ListView.setAdapter(ma).
You should also have MyAdapter.getItemId(int position) return position instead of 0.
I have a button in each list item of list view. In that button click event i have some codes to run. In click event im showing the progress dialog before the code runs. but its not getting shown. After all the codes in click event completes in the end progress dialog gets shown. Plz help me.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity1);
TheListViewM = (ListView) findViewById(R.id.lvItems);
ImageAdapter anImageAdapterM =new ImageAdapter(this);
TheListViewM.setAdapter(anImageAdapterM);
}
public class ImageAdapter extends BaseAdapter {
private Context mContextL;
public ImageAdapter(Context contextP) {
mContextL = contextP;
}
public int getCount() {
return ItemList.GetLength();
}
public Object getItem(int PositionP) {
return ItemList.GetObject(PositionP);
}
public long getItemId(int PositionP) {
return PositionP;
}
public View getView(final int PositionP, View ConvertViewP, ViewGroup ParentP) {
if (ConvertViewP == null) {
LayoutInflater inflater = (LayoutInflater) mContextL.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ConvertViewP = inflater.inflate(R.layout.add_cart_row_layout, ParentP, false);
}
TextView textView1 = (TextView) ConvertViewP.findViewById(R.id.tvName);
textView1.setText("asdfg");
final Spinner spQuantity = (Spinner) ConvertViewP.findViewById(R.id.spQuantity);
spQuantity.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> Parent, View view,
int pos, long id) {
ProgressDialog aProgressDialogL = new ProgressDialog(mContextL);
aProgressDialogL.setMessage("Loading...");
aProgressDialogL.show();
//Processiing codes
}
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
ArrayAdapter<String> QuantityAdapter1 = new ArrayAdapter<String>(mContextL,android.R.layout.simple_spinner_item, QuantityList);
QuantityAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spQuantity.setAdapter(QuantityAdapter1);
Button btn1 = (Button) ConvertViewP.findViewById(R.id.btn1);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ProgressDialog aProgressDialogL = new ProgressDialog(activity1.this);
aProgressDialogL.setMessage("Loading...");
aProgressDialogL.show(); }
});
return ConvertViewP;
}
Try this one.
public class ImageAdapter extends BaseAdapter {
private Context mContextL;
public ImageAdapter(Context contextP) {
mContextL = contextP;
}
public int getCount() {
return ItemList.GetLength();
}
public Object getItem(int PositionP) {
return ItemList.GetObject(PositionP);
}
public long getItemId(int PositionP) {
return PositionP;
}
class ViewHolder {
Button btn1;
TextView textView1;
Spinner spQuantity;
}
public View getView(final int PositionP, View ConvertViewP, ViewGroup ParentP) {
ViewHolder holder;
if (ConvertViewP == null) {
holder = new ViewHolder();
LayoutInflater inflater = (LayoutInflater) mContextL.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ConvertViewP = inflater.inflate(R.layout.add_cart_row_layout, ParentP, false);
holder.textView1 = (TextView) ConvertViewP.findViewById(R.id.tvName);
holder.spQuantity = (Spinner) ConvertViewP.findViewById(R.id.spQuantity);
holder.btn1 = (Button) ConvertViewP.findViewById(R.id.btn1);
ConvertViewP.setTag(holder);
}
else{
holder = (ViewHolder) ConvertViewP.getTag();
}
holder.textView1.setText("asdfg");
holder.spQuantity.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> Parent, View view,
int pos, long id) {
ProgressDialog aProgressDialogL = new ProgressDialog(mContextL);
aProgressDialogL.setMessage("Loading...");
aProgressDialogL.show();
//Processiing codes
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
ArrayAdapter<String> QuantityAdapter1 = new ArrayAdapter<String>(mContextL,android.R.layout.simple_spinner_item, QuantityList);
QuantityAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
holder.spQuantity.setAdapter(QuantityAdapter1);
holder.btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ProgressDialog aProgressDialogL = new ProgressDialog(activity1.this);
aProgressDialogL.setMessage("Loading...");
aProgressDialogL.show(); }
});
return ConvertViewP;
}
}
I Have 2D Array and this 2D Array has Strings. I would like to know How to Display the Strings in ListView?how to scroll both vertically and horizontally?
String[][] board = new String[][] {{"1","10","100"},{"hi0","1hello","test"},{"test31","test32","test43"}};
It seem to be you are asking basic things, How to use ListView. please check it you will get all about ListView.
Android ListView and ListActivity
It is to display two-d array in list view.Here's my source code in which i have implemented 2-d array in list view
My Adapter class:-
public class MyArrayAdapter extends ArrayAdapter<List>{
QuickActionDemo quickActionDemo;
public Activity context;
public List<List> list;
int CAMERA_PIC_REQUEST=10;
private int selectedPos = -1;
int clickPosition,rowPosition;
Camera camera;
private static final String TAG = "CameraDemo";
public MyArrayAdapter(Activity context,List<List> list) {
super(context,R.layout.attach_pic,list);
this.context = context;
this.list = list;
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position+1;
}
static class ViewHolder {
public TextView tv1,tv2,tv3;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
View rowView = null;
final ViewHolder holder = new ViewHolder();
if (convertView == null) {
LayoutInflater inflator = context.getLayoutInflater();
rowView = inflator.inflate(R.layout.attach_pic, null);
holder.tv1 = (TextView) rowView.findViewById(R.id.defectpic);
holder.tv2 = (TextView) rowView.findViewById(R.id.no_of_uploded_pics);
holder.tv3 = (TextView) rowView.findViewById(R.id.camera);
holder.tv3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
// Intent in = new Intent(getContext(),QuickActionDemo.class);
// context.startActivityForResult(in,0);
}
});
rowView.setTag(holder);
List itemVal1 = (List)getItem(position);
String st1 = (String)itemVal1.get(0);
holder.tv1.setText(st1);
List itemVal2 = (List)getItem(position);
String st2 = (String)itemVal2.get(1);
holder.tv2.setText(st2);
} else {
rowView = convertView;
((ViewHolder) rowView.getTag()).tv1.setTag(list.get(position));
((ViewHolder) rowView.getTag()).tv2.setTag(list.get(position));
((ViewHolder) rowView.getTag()).tv3.setTag(list.get(position));
}
return rowView;
}
#Override
public int getItemViewType(int position) {
// TODO Auto-generated method stub
return position;
}
#Override
public int getViewTypeCount() {
// TODO Auto-generated method stub
return list.size();
}
}
Here's my activity class:-
public class MyActivity extends ListActivity {
Context context;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // to hide the virtual keyboard
setContentView(R.layout.defect_pic_listview);
try{
ArrayAdapter<List> adapter = new MyArrayAdapter(this,makeList());
setListAdapter(adapter);
}
}
private List<List> makeList(){
List<List> all = new ArrayList();
String[] newArray1 = {"Defect Picture1", "2"};
List<String> newListObject1 = Arrays.asList(newArray1);
String[] newArray2 = {"Defect Picture2","1"};
List<String> newListObject2 = Arrays.asList(newArray2);
String[] newArray3 = {"Defect Picture3","4"};
List<String> newListObject3 = Arrays.asList(newArray3);
String[] newArray4 = {"Defect Picture4","1"};
List<String> newListObject4 = Arrays.asList(newArray4);
String[] newArray5 = {"Defect Picture5","3"};
List<String> newListObject5 = Arrays.asList(newArray5);
all.add(newListObject1);
all.add(newListObject2);
all.add(newListObject3);
all.add(newListObject4);
all.add(newListObject5);
return all;
}
}
Creating a model as an inner class always works well.
Good way to store any number of items.
public class ActivityClass extends Activity {
...
ArrayList<ValuesModel> listViewValues = new ArrayList<ValuesModel>();
listViewValues.add(new ValuesModel("row title", "row details"));
ListViewAdapter listAdapter = new ListViewAdapter(this, listViewValues);
((ListView) findViewById(android.R.id.list)).setAdapter(listAdapter);
...
public class ValuesModel {
private String rowTitle;
private String rowDetails;
public ValuesModel(String rowTitle, String rowDetails) {
this.rowTitle = rowTitle;
this.rowDetails = rowDetails;
}
public String getRowTitle() {
return rowTitle;
}
public String getRowDetails() {
return rowDetails();
}
}
Then inside of your list adapter,
public class ListViewAdapter extends ArrayAdapter<ActivityClass.ValuesModel> {
private ArrayList<ActivityClass.ValuesModel> mValues;
...
#Override
public View getView(int position, View convertView, ViewGroup parent) {
...
//here whenever you need to retrieve your values, just say:
// mValues.get(position).getRowTitle();
// mValues.get(position).getRowDetails();
//if you use a viewholder pattern, you can do this:
viewHolder.rowTitle = (TextView) convertView.findViewById(R.id.row_title_textview);
viewHolder.rowTitle.setText(mValues.get(position).getRowTitle());
...
}
}