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 6954289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:35:13+00:00 2026-05-27T14:35:13+00:00

In My Activity there are more then one ListView. See the XML Layout of

  • 0

In My Activity there are more then one ListView.
See the XML Layout of it:

<RelativeLayout  
    android:id="@+id/taxCodeLayout"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:orientation="vertical" android:visibility="gone">
    <EditText 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent" 
        android:singleLine="true" 
        android:id="@+id/taxcode_EditText" 
        android:gravity="center"
        android:textColor="#000000" 
        android:textSize="14sp" 
        android:cursorVisible="false"
        android:focusable="false"
        android:hint="tax code"/>
    <ListView 
        android:id="@+id/android:list" 
        android:cacheColorHint="#00000000"
        android:layout_centerInParent="true"
        android:layout_centerHorizontal="true"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:layout_below="@+id/taxcode_EditText"/>
</RelativeLayout>

<!-- ============================================================== -->
<!-- PAYE Frequency Layout start-->
<!-- ============================================================== -->
<RelativeLayout  
    android:id="@+id/payeFrequencyLayout"  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:orientation="vertical" 
    android:visibility="gone">
    <EditText 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent" 
        android:singleLine="true" 
        android:id="@+id/payFrequencyEditText" 
        android:gravity="center"
        android:textColor="#000000" 
        android:textSize="14sp" 
        android:cursorVisible="false"
        android:focusable="false"
        android:hint="pay frequency" 
        android:layout_weight="1"/>
    <ListView 
        android:id="@+id/android:list" 
        android:cacheColorHint="#00000000"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:layout_weight="1" 
        android:layout_below="@+id/payFrequencyEditText"/>
</RelativeLayout>

Now i am able to access the first ListView with this code:

setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, TAXCODE));  
getListView().setTextFilterEnabled(true);
taxCode_EditText.setText(TAXCODE[0]);
//taxCodeFinalValue = taxCode_EditText.getText().toString();
lv1 = getListView();
lv1.setOnItemClickListener(new OnItemClickListener()
{
    public void onItemClick(AdapterView<?> parent, View view,final int Position,long id)
    {
        taxCode_EditText.setText(TAXCODE[Position].toString());
        //prefsEditor.commit(); 
    }
});

But now if i access the second ListView with the below code it is not working. I am not able to see any Second ListView.

So Whats wrong in my Code?
Why i am not able to see the Second LiStView ?
Thanks.

Edited:

After Answer i have set the second listview as like below code but still not get any listview.
code:

ListView payFrequencyListView = (ListView) findViewById(R.id.payFrequencyListView);
        payFrequencyListView = getListView();
        payFrequencyListView.setTextFilterEnabled(true);
        Adapter mySecondAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_2, PAY_FREQUENCY);  
        payFrequencyEditText.setText(PAY_FREQUENCY[0]);
        payFrequencyListView.setAdapter((ListAdapter) mySecondAdapter);

        payFrequencyListView.setOnItemClickListener(new OnItemClickListener()
        {
            public void onItemClick(AdapterView<?> parent, View view,final int Position,long id)
            {
                payFrequencyEditText.setText(PAY_FREQUENCY[Position].toString());
                //prefsEditor.commit(); 
            }
        });
  • 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-27T14:35:14+00:00Added an answer on May 27, 2026 at 2:35 pm

    setListAdapter() and getListView() in a ListViewActivity will only work with THE list having “@id/android:list” as an id.

    If you want to manage 2 listviews, you will need to set another id to the second one and
    retreive it using a good old findViewById(), casting it to ListView and then setting your adapter to it using setAdapter().

    Layout:

    <ListView 
            android:id="@+id/my_second_list_id" 
            android:cacheColorHint="#00000000"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:layout_weight="1" 
            android:layout_below="@+id/payFrequencyEditText"/>
    

    ListViewActivity:

    Adapter mySecondAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_2, TAXCODE)); 
    ListView mySecondListview = (ListView)findViewById(R.id.my_second_list_id);
    mySecondListview.setAdapter(mySecondAdapter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an android Activity is there a way to programmatically list the it has
I would know if there is the possibility to create a new Android Activity
I have some problem with Android AsyncTask. There is an Activity which contains some
Alright, so i have an Activity. In the activity there is a textview and
Is there a way to vizualise the activity stack, at some moment during debug,
is there a way to create a task/activity report (say a weekly report) off
Is there a way to find out if an activity is bound to a
Is there any command i can use in activity class that disables TextViews that
After tracing the DB activity from a DNN 5.2.3 site I noticed that there
I am trying to add ListView items one by one. So if I have

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.