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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:43:20+00:00 2026-06-13T16:43:20+00:00

As I am working on getting a custom spinner and displaying the value in

  • 0

As I am working on getting a custom spinner and displaying the value in toast. The values are setting to the spinner correctly but I am unable to display them in toast. My code is

Main.java

public class Main extends Activity {
ArrayList<String> ast = new ArrayList<String>();
Spinner customspinner;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    customspinner = (Spinner)findViewById(R.id.spinner1);

    ast.add("111111");
    ast.add("222222");
    ast.add("333333");
    ast.add("444444");

    MyAdapter adp = new MyAdapter();
    customspinner.setAdapter(adp);
    System.out.println(ast);
    customspinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapter, View v,
                int position, long val) {
            // TODO Auto-generated method stub
    //here when spinner was selected I need to save those two custom textviews in two string and need to display them in toast....
            //String getspineer = customspinner.getSelectedItem().toString();
            //Toast.makeText(getApplicationContext(), "spinner  --- " + getspineer , Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub  
        }
    });
}


public class MyAdapter extends BaseAdapter{

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return ast.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        View v = null;
        LayoutInflater inflater = getLayoutInflater();
        v = inflater.inflate(R.layout.customspinner, null);
        TextView tv = (TextView)v.findViewById(R.id.textView1);
        TextView tv1 = (TextView)v.findViewById(R.id.textView2);
        String arlstdate[] = ast.get(position).split("~");
        for (int i = 0; i < arlstdate.length; i++) {
            tv.setText(arlstdate[i]);
            tv1.setText(arlstdate[i]);
        }
        return v;
    }
} 

}

Here what I am looking for is, when I select spinner, I need to save the following two textview values in two string and need to display them in Toast mess seperately.

Can anyone help me with this. After a lot of search I found this code but unable to save to text values in string & display..

  • 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-13T16:43:21+00:00Added an answer on June 13, 2026 at 4:43 pm

    I don’t really get exactly what you mean sorry, but as a pointer, the content of the view at that position on the spinner is the same as the string at same position on the ArrayList you used to populate the adapter.

    So you can take the value from the ArrayList not from the Spinner View.

        @Override
        public void onItemSelected(AdapterView<?> adapter, View v, int position, long val) {
            String getspineer = ast.get(position);
            Toast.makeText(getApplicationContext(), "spinner  --- " + getspineer , Toast.LENGTH_SHORT).show();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am unable to get a custom binding working with a converter, getting this
My custom error messages quit working somewhere along the way and I'm getting this
Has anyone found a workaround yet for getting custom dictionary support working for the
I am using a custom font using @font-face . Everything is working but some
I'm struggling with getting a custom attribute / filter working with ninject, constructor injection
I'm working on activecollab custom module's permissions, and getting this error message when try
I'm working on my first GAE project and I'm having some trouble getting custom
I am getting an error like this all other pages working perfectly but getting
I am getting some strange results when working with a custom script to verify
I am not getting an error now but my delegate is not working. I

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.