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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:06:53+00:00 2026-06-15T08:06:53+00:00

There is a ListView in layout of my Activity. listview_layout.xml <?xml version=1.0 encoding=utf-8?> <LinearLayout

  • 0

There is a ListView in layout of my Activity.
listview_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ListView android:layout_width="wrap_content"    
        android:layout_height="wrap_content"    
        android:id="@+id/MyListView" />
</LinearLayout>

I am using another layout for ListItem of ListView.

listitem_layout.xml

<?xml version="1.0" encoding="utf-8"?>  
<RelativeLayout    
    android:id="@+id/RelativeLayout01"    
    android:layout_width="fill_parent"    
    xmlns:android="http://schemas.android.com/apk/res/android"    
    android:layout_height="fill_parent">  

    <TextView
        android:id="@+id/txtTitle"
        android:layout_width="80dp"
        android:layout_height="wrap_content" />

    <Spinner 
        android:id="@+id/MySpinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>  

My Activity’s layout is the same with the listview_layout.xml’s.

I use SimpleAdapter cited the layout of listitem_layout.xml.

The problwm: Now I want to get the Spinner control ID of listview_layout.xm.

I use findViewById(MySpinner) in activity of ListView, it has the error of null pointer exception.
can not find. Because the Activity layout files use the listview_layout.xml’s and Spinner control in listview_layout.xml.

anyone’s help is very thankful.

  • 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-15T08:06:54+00:00Added an answer on June 15, 2026 at 8:06 am

    you cannot directly use the findViewById(spinnerId). You have to override the getView() method of Custom Adapter instead of Simple Adapter and inside that inflate the listitem_layout to a view(v) and then use v.findViewById(spinnerId).

    Refer the below link which will help you in creating custom adapter (Weather Adapter in the link’s example). in the example ImageView object is created in the GetView method. Instead of that you use Spinner.

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

Sidebar

Related Questions

I have the following layout: <?xml version=1.0 encoding=utf-8?> <FrameLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical android:background=#EAEAEA>
I have such a activity with my list: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
In My Activity there are more then one ListView. See the XML Layout of
In my android app, there is a xml file called mylistview : <?xml version=1.0
i'm trying to develop the given UI in android, there is a ListView and
I've passes by this tutorial: Android: Creating and populating ListView items in XML I
I set one Gribview and one listview in an Activity,In the Gridview there is
I have the following application layout: Activity with a LinearLayout hosting a Fragment, which
I am new to Android development. I have created an Activity with the ListView
I have a class that extends Activity and inflates another xml layout in the

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.