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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:57:19+00:00 2026-06-07T14:57:19+00:00

I have a global variable myval which is of String type. String[] Category={—-SELECT—-,BEVERAGES,BREAKFAST,LUNCH,DINNER,DESSERTS,APPETIZERS &

  • 0

I have a global variable myval which is of String type.

String[] Category={"----SELECT----","BEVERAGES","BREAKFAST","LUNCH","DINNER","DESSERTS","APPETIZERS & SIDES"};
String[] Beverage={"PEPSI","COKE","LASSI","FALOODA","BUTTER MILK","GREEN TEA","BADAM MILK","MASALA CHAI" };
String[] Breakfast={"SIRLOIN & EGG","CFS STEAK & EGG","T-BONE & EGG","TWO EGGS BREAKFAST","2EGG W/MEAT","BEL WAFFLE","BEL WAFFLE W/MEAT","BLUEBERRY CAKE","CAKES","FABULOUS FRENCH TST","MOONS","FRENCH TST"};
String[] Lunch={" CRAB CAKE SANDWICH","TUSCAN GRILLED CHICKEN PANINI","SOUTHWEST TURKEY CLUB"," LOBSTER ROLL","TUNA MELT"," FRENCH DIP","YOUR OWN SANDWICH"};
String[] Dinner={"DUBLIN BAY PRAWN","CRAB FROM BRITTANY","WHITE ASPARAGUS","BLEWIT MUSHROOM","JOHN DORY FISH","MONKFISH","VEAL SWEET BREAD","LAMB","PIGEON FRY"};
String[] Desserts={"ECHOURGNAC CHEESE","HAZELNUT","GARIGUETTE STRAWBERRY","MOUSSE & ZEST","APRICOT","CHOCOLATE"};
String[] Appetizers={"Greek Artichoke Spinach","Seafood Appetizers","Tapenade Flatbread","Cranberry Blue Cheese","Fig and Blue Cheese","Sun-Dried Tomato","Tropical Crab Rangoon"};

class GlobalClass extends Application {
     public static String[] myval;

}   

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
    spinner = (Spinner) findViewById(R.id.spinnerCategory);
    l1=(ListView) findViewById (R.id.list);
    b1=(Button)findViewById(R.id.button3);
    b2=(Button)findViewById(R.id.button2);
    b3=(Button)findViewById(R.id.button1);
    e1=(EditText)findViewById(R.id.editText1);
    e2=(EditText)findViewById(R.id.editText2);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, Category);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    final ArrayAdapter<String> bever = new ArrayAdapter<String>(this,        android.R.layout.simple_list_item_1, Beverage);

    // Assign adapter to ListView
    final ArrayAdapter<String> Breakf = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, Breakfast);
    final ArrayAdapter<String> lunc= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, Lunch);     
    final ArrayAdapter<String> Dinn= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, Dinner);     
    final ArrayAdapter<String> Dessert = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, Desserts);     
    final ArrayAdapter<String> Appet= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, Appetizers);     

    spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
         public void onItemSelected(AdapterView<?> parent, View arg1, int pos,long id){           
             String Text = parent.getSelectedItem().toString();
             if(Text.equals("----SELECT----")) {                
             }      
             else if(Text.equals("BEVERAGES")){

            l1.setAdapter(bever);              
            return;
             }    
             else if(Text.equals("BREAKFAST")){

            l1.setAdapter(Breakf);
            return;
             }
             else if(Text.equals("LUNCH")){

            l1.setAdapter(lunc);
            return;
             }
             else if(Text.equals("DINNER")){
            l1.setAdapter(Dinn);
            return;            
             }
             else if(Text.equals("DESSERTS")){
            l1.setAdapter(Dessert);
            return;            
             }
             else if(Text.equals("APPETIZERS & SIDES")){
            l1.setAdapter(Appet);
            return;            
             }
         }
         public void onNothingSelected(AdapterView<?> arg0){
         }             
     });
     l1.setOnItemClickListener(new OnItemClickListener() {

         public void onItemClick(AdapterView<?> parent, View view,int position, long id) {                      
              // When clicked, show a toast with the TextView text
              Toast.makeText(getApplicationContext(), "SELECTED :: " +((TextView) view).getText(),
              Toast.LENGTH_SHORT).show();
              long ii=(long) l1.getItemIdAtPosition((int) id);
              //Get the value from listView click item                   
              String[] S5=new String[]{a5};
              //String[] S1=new String[]{s2};
              GlobalClass.myval=S5;
        });            
        b1.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                 String tno = e1.getText().toString();
                 int tn = Integer.parseInt(tno);

                 Intent i=new Intent(getApplicationContext(),TicketActivity.class);
                 Bundle b=new Bundle();
                 b.putInt("Table No:", tn);
                 i.putExtras(b);
                 String et= e2.getText().toString();
                 int et1 = Integer.parseInt(et);
                 Bundle be=new Bundle();
                 be.putInt("Guest:", et1);
                 i.putExtras(be); 

                 startActivity(i);                    
            }
        });            
        b3.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent intent=new Intent(HomeActivity.this,PaynowActivity.class);
                startActivity(intent);
            }
        });             
        b2.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent m=new Intent(HomeActivity.this,OrderinfoActivity.class);
                startActivity(m);
            }
        });
    }        
} 

How do I get the value from onItemClick in the ListView?

  • 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-07T14:57:22+00:00Added an answer on June 7, 2026 at 2:57 pm
     ArrayAdapter<String> adapter=new ArrayAdapter<String>(HotelActivity.this, android.R.layout.simple_list_item_1,Category);
            listView.setAdapter(adapter);
    
            listView.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View v, int position,
                        long id) {
                    if(position>0){
                        Intent intent=new Intent(HotelActivity.this,NewList.class);
                        intent.putExtra("position", position);
                        startActivity(intent);
                    }
                }
            });
    

    Create new Activity and declare listview in its xml file

    NewList Activity:

    public class NewList extends Activity{
        ListView listView;
        int pos=0;
        ArrayAdapter<String> adapter;
        String[] Beverage={"PEPSI","COKE","LASSI","FALOODA","BUTTER MILK","GREEN TEA","BADAM MILK","MASALA CHAI" };
        String[] Breakfast={"SIRLOIN & EGG","CFS STEAK & EGG","T-BONE & EGG","TWO EGGS BREAKFAST","2EGG W/MEAT","BEL WAFFLE","BEL WAFFLE W/MEAT","BLUEBERRY CAKE","CAKES","FABULOUS FRENCH TST","MOONS","FRENCH TST"};
        String[] Lunch={" CRAB CAKE SANDWICH","TUSCAN GRILLED CHICKEN PANINI","SOUTHWEST TURKEY CLUB"," LOBSTER ROLL","TUNA MELT"," FRENCH DIP","YOUR OWN SANDWICH"};
        String[] Dinner={"DUBLIN BAY PRAWN","CRAB FROM BRITTANY","WHITE ASPARAGUS","BLEWIT MUSHROOM","JOHN DORY FISH","MONKFISH","VEAL SWEET BREAD","LAMB","PIGEON FRY"};
        String[] Desserts={"ECHOURGNAC CHEESE","HAZELNUT","GARIGUETTE STRAWBERRY","MOUSSE & ZEST","APRICOT","CHOCOLATE"};
        String[] Appetizers={"Greek Artichoke Spinach","Seafood Appetizers","Tapenade Flatbread","Cranberry Blue Cheese","Fig and Blue Cheese","Sun-Dried Tomato","Tropical Crab Rangoon"};
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.mylist);
    
    
            listView=(ListView) findViewById(R.id.newlist);
            Bundle bundle=getIntent().getExtras();
            if(bundle!=null){
                pos=bundle.getInt("position");
            }
    
            if(pos==1){
                adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,Beverage);
                listView.setAdapter(adapter);
            }
            else if(pos==2){
                adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,Breakfast);
                listView.setAdapter(adapter);
            }
            else if(pos==3){
                adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,Lunch);
                listView.setAdapter(adapter);
            }
            else if(pos==4){
                adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,Dinner);
                listView.setAdapter(adapter);
            }
            else if(pos==5){
                adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,Desserts);
                listView.setAdapter(adapter);
            }
            else if(pos==6){
                adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,Appetizers);
                listView.setAdapter(adapter);
            }
        }
    
    }
    

    Hope this will help you.

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

Sidebar

Related Questions

I have a global variable I called Y_VAL which is initialized to a value
I have a global variable: const std::string whiteSpaceBeforeLeadingCmntOption = WhiteSpaceBeforeLeadingComment; When I remove the
I am developing a shared library(.so) and dll. I have a global variable which
I have a global variable which needs to be initialized when the store is
So lets say I have this global variable foo , which while my server
I have this global variable which is used as counter which I want to
I have a global variable which was declared in a formula in the Report
I have a global variable which is an instance of a class. This class
I want to have a global names variable, which looks like that char* names[NAMES_CAP];
If i have global variable in A.dll, that depends on global variable in B.dll

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.