Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7553111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:57:33+00:00 2026-05-30T10:57:33+00:00

I have: One MyListActivity class extends ListActivity setContentView(R.layout.mylist) ; Two xml files: mylist.xml and

  • 0

I have:

  1. One MyListActivity class extends ListActivity setContentView(R.layout.mylist);
  2. Two xml files: mylist.xml and list_row.xml.
  3. mylist.xml is the layout and list_row.xml is how each row looks like.
  4. list_row.xml contains 3 TextViews(t1,t2,t3).

I want to change some text of t2 in MyListActivity class. Because the content view is mylist.xml so I can’t simply use findViewById. So I used LayoutInflater.

    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.list_row, null);

    textView2 = (TextView) v.findViewById(R.id.t2);
    textView2.setText("ccccc");

The problem is that the text of t2 is never changed. I have tried many times and the text remains the text I set in the list_row.xml. I can’t figure out why.. Could someone help please. Thanks!

=====Solution:=====

Create my own SimpleCursorAdapter class and override the getView() method.

private class MySimpleCursorAdapter extends SimpleCursorAdapter {
    Cursor c;
    public MySimpleCursorAdapter(Context context, int layout, Cursor c,
            String[] from, int[] to) {
        super(context, layout, c, from, to);
        this.c = c;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        super.getView(position, convertView, parent);
        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.list_row, parent, false);
        TextView textview1 = (TextView) rowView.findViewById(R.id.text1);
        textView1.setText(c.getString(1));// whatever should be in textView1
        textView2 = (TextView) rowView.findViewById(R.id.text2);
        textView2.setText("ccccc");
        return rowView;
    }
}

The super.getView(position, convertView, parent); is quite important because if I don’t have that line, textView1 will always show the value of first row(e.g. if textView1 shows the id, then this is always 1).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:57:36+00:00Added an answer on May 30, 2026 at 10:57 am

    If you want to change the TextView text you will have to do it in the adapter of the ListView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView where each row has two webviews side by side, taking
I have one server which has nothing but xls log files. Each file is
I have one test project for each project in my solution. Is there a
I have a ListActivity which shows list of items. I prepared another layout for
I have one many-to-many relationship in my model. There are two entities, Emergencies and
i have one xml file. lets say sample.xml with random position of tabs and
I have one class that shows me a list of Items. Right now I
I have one folder named library where I have put all my JAR files.
I have one view ,view contains two buttons and one gallery. Gallery view pleased
I have one schema file that I'm using to generate java files. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.