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

  • Home
  • SEARCH
  • 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 7711397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:21:54+00:00 2026-06-01T01:21:54+00:00

I setup a listview with a layout XML for each row: this.setContentView(R.layout.item_view); ListView m_ListView

  • 0

I setup a listview with a layout XML for each row:

    this.setContentView(R.layout.item_view);

    ListView m_ListView = this.getListView();
    m_ListView.setTextFilterEnabled(true);
    m_ListView.setItemsCanFocus(false);
    m_ListView.setCacheColorHint(0x00000000);
    mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    ArrayList<View> views=new ArrayList<View>();
    e = mInflater.inflate(R.layout.item_first, null);

    views.add(e);

    r = mInflater.inflate(R.layout.item_second, null);

    views.add(r);


    mAdapter = new SillyAdapter(views);
    setListAdapter(mAdapter);

now for example i have a TextView in item_first and i want to set it from the code:

    TextView name = (TextView)findViewById(R.id.textView1);
    name.setText(m_item.name);

but name is always null.any idea why it happen?

  • 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-06-01T01:21:55+00:00Added an answer on June 1, 2026 at 1:21 am

    You have to do the following changes in your code.

    TextView name = (TextView)e.findViewById(R.id.textView1);
    name.setText(m_item.name);
    

    You are getting name as null since you are calling findViewById method from wrong view or might be calling from activity.
    since you are inflating as follows

     e = mInflater.inflate(R.layout.item_first, null);
    

    you have to call findViewById on inflated view e. so that you will get the instance of textview with id R.id.textView1 contained in xml R.layout.item_first

    Hope this will help.

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

Sidebar

Related Questions

I'm using a ListView that is setup like this: <ListView android:id=@android:id/list android:layout_width=fill_parent android:layout_height=fill_parent android:longClickable=false
I use following GUI setup: ListView activity CursorAdapter that feeds this list Layout for
I have a ListView setup in details mode that looks like this: When the
I have an activity, where the ListView holds customized linear layout elements for each
I have a a listview with each row having a text field and edittext
I've setup my activity to have a listview-> Listview-> listview-> table layout -> etc.
I have a ListView, and I want to customize the layout of each item
I have a simple listview and listadapter setup as follows: listAdapter = new ArrayAdapter<MyDomainObject>(this,
I have a custom dialog that uses an xml file to setup the layout,
My Listview is setup in the details view with the following column headers: Image

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.