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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:08:04+00:00 2026-05-25T02:08:04+00:00

In my application, i have activity group in which i have a custom ListView

  • 0

In my application, i have activity group in which i have a custom ListView with ImageView, TextView and a spinner. Error comes when i click on the spinner. here is the code..

final ListView list = (ListView)findViewById(R.id.submenu_list);

         MyCustomAdapter adapter = new MyCustomAdapter(this, mylist, 0, null, null);
        list.setAdapter(adapter);
        list.setTextFilterEnabled(true);


private class MyCustomAdapter extends SimpleAdapter {

        public MyCustomAdapter(Context context,
        List<? extends Map<String, ?>> data, int resource,
        String[] from, int[] to) {
            super(context, data, resource, from, to);
        }

        public View getView(final int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = getLayoutInflater().inflate(R.layout.submenu_items,
             null);

            }

 ((TextView) convertView.findViewById(R.id.food_name))
         .setText(estimated[position]);

 ((TextView) convertView.findViewById(R.id.prize))
 .setText("Price : "+price[position]);

 ((ImageView) convertView.findViewById(R.id.imageview))
         .setImageResource(image[position]);



 Spinner spinner = (Spinner) convertView.findViewById(R.id.spinner);

    ArrayAdapter<CharSequence> sadapter = ArrayAdapter.createFromResource(getParent(), R.array.number, android.R.layout.simple_spinner_item);
    sadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(sadapter);


 return convertView;
}

}

In my another activity inside activity group, i have simple layout with spinner. To generate the spinner i have my code as below:

 public class FoodDetailPage extends Activity {

    Spinner spinner;
    Button back_button,my_order,add_order;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.food_details, null);
        this.setContentView(viewToLoad); 

        back_button = (Button) findViewById(R.id.back_button);

        add_order = (Button) findViewById(R.id.add_order);

        back_button.setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                Intent intent =new Intent(FoodDetailPage.this,SubMenu.class);
                startActivity(intent);
            }
        });


        this.spinner =(Spinner) findViewById(R.id.spinner);

        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.number, R.layout.spinnerlayout);
        adapter.setDropDownViewResource(R.layout.spinnerlayout);
        spinner.setAdapter(adapter);

    }

Problem is when placing a spinner in custom ListView with Activity group, my application hangs.

  • 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-25T02:08:05+00:00Added an answer on May 25, 2026 at 2:08 am

    Try passing this.getPrent() to the MyCustomAdapter like this:

    MyCustomAdapter adapter = new MyCustomAdapter(this.getPrent(), mylist, 0, null, null);
    

    and make a Context variable in the MyCustomAdapter

    private class MyCustomAdapter extends SimpleAdapter {
            Context mContext;
            public MyCustomAdapter(Context context,List<? extends Map<String, ?>> data, int resource, String[] from, int[] to)
            {
                super(context, data, resource, from, to);
                mContext = context;
            }
            //getView implementation
    }
    

    and pass that mContext to the ArrayAdapter inside getView()

    ArrayAdapter.createFromResource(mContext, R.array.number, android.R.layout.simple_spinner_item);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my console application have an abstract Factory class Listener which contains code for
Actually in my application i have set an activity as main activity in which
I have created an application having tab activity which in turn has 5 different
I have used tabbar with activity group in my application. I have four tab
In my application i have three activity. In my third activity if i click
i have the following flow of activity in my application, Main actitvity->tag group(contain three
I have an application that records activity in a table (Oracle 10g). The logging
I have to create a UML activity diagrams for a searching application for a
I have a web-based application that notifies users of activity on the site via
I have to include one report in my application showing offline/online activity of few

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.