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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:11:47+00:00 2026-05-27T06:11:47+00:00

Hi thanks for reading this! Please help me. I am trying to create a

  • 0

Hi thanks for reading this! Please help me.

I am trying to create a restaurant app which the display 3 buttons in the menu then click the food button which display the list of food, then customer can choose the food they want to order then send back the order back to first page. I read a lot of the article and some say use the listview.setItemsCanFocus(true) but I having problem to understand it to implement it. and some say the button listener inside the getView but when I implement my program just hang. Please help me. Thank you.

my menu :
enter image description here

here is my food(second) page

enter image description here

I am having problems:

  1. to transfer the data back from the food.class back to my main class which is
    restaurant.class

  2. After I add the button in the list the food is not clickable(the whole row of food).

my main class(restaurant)

public class SesameRestaurant extends Activity  {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

}


public void foodMenu(View v){
    startActivity(new Intent(SesameRestaurant.this,Food.class));

    //setContentView(R.layout.foods);
}

public void drinkMenu(View v){startActivity(new Intent(SesameRestaurant.this,Drink.class));}
public void billMenu(View v){}

}

my second class (food.class)

package com.restaurant.sesame;

 public class Food extends ListActivity {
private LayoutInflater mInflater;
private Vector<RowData> data;
RowData rd; 


static final String[] title = new String[] {
            "Cow Rib steak", 
            "Thai Prawn Fried Rice",    
            "Christmas Sensation Delight",
            "Salmon Steak"      };

static final String[] detail = new String[] {
                "1h 37m Shipping: $10.00",
                "1h 39m Shipping: Free",
                "58m 6s Shipping: $10.00",
                "59m 30s Shipping: $10.95"  };

private Integer [] imgid = { R.drawable.food1, R.drawable.food2, R.drawable.food3, R.drawable.food4 };


public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.foods);

    mInflater = (LayoutInflater) getSystemService(
            Activity.LAYOUT_INFLATER_SERVICE);
            data = new Vector<RowData>();
            for(int i=0;i<title.length;i++){
            try {
                rd = new RowData(i,title[i],detail[i]);
                } catch (ParseException e) {
                    e.printStackTrace();
               }
               data.add(rd);
            }
               CustomAdapter adapter = new CustomAdapter(this, R.layout.list, R.id.title, data);
               setListAdapter(adapter);
               getListView().setTextFilterEnabled(true);

}

 public void onListItemClick(ListView parent, View v, int position, long id) {          
     Log.w("my app", "Click list Item!!!"); 
     Toast.makeText(getApplicationContext(), "You have selected "+(position+1)+"th item",  Toast.LENGTH_SHORT).show();
 }

 public void orderClick(View v){


 }

 private class RowData {
        protected int mId;
        protected String mTitle;
        protected String mDetail;

     RowData(int id,String title,String detail)
     {
                mId=id;
                mTitle = title;
                mDetail=detail;
     }

     @Override
     public String toString() {
         return mId+" "+mTitle+" "+mDetail;
     }
 }

 private class CustomAdapter extends ArrayAdapter<RowData> {
     public CustomAdapter(Context context, int resource, int textViewResourceId, List<RowData> objects) {               
         super(context, resource, textViewResourceId, objects);
     }

     @Override
     public View getView(int position, View convertView, ViewGroup parent) {   
         ViewHolder holder = null;
         TextView title = null;
         TextView detail = null;
         ImageView i11=null;
         RowData rowData= getItem(position);
         if(null == convertView){
                convertView = mInflater.inflate(R.layout.list, null);
                holder = new ViewHolder(convertView);
                convertView.setTag(holder);
         }
         holder = (ViewHolder) convertView.getTag();
         title = holder.gettitle();
         title.setText(rowData.mTitle);
         detail = holder.getdetail();
         detail.setText(rowData.mDetail);                                                     
         i11=holder.getImage();
         i11.setImageResource(imgid[rowData.mId]);


         return convertView;
     }

     private class ViewHolder {
         private View mRow;
         private TextView title = null;
         private TextView detail = null;
         private ImageView i11=null; 
         public ViewHolder(View row) {
             mRow = row;
         }

         public TextView gettitle() {
             if(null == title){
                 title = (TextView) mRow.findViewById(R.id.title);
             }
             return title;
         }     

         public TextView getdetail() {
             if(null == detail){
                 detail = (TextView) mRow.findViewById(R.id.detail);
             }
             return detail;
         }
         public ImageView getImage() {
             if(null == i11){
                 i11 = (ImageView) mRow.findViewById(R.id.img);
             }
             return i11;
         }
     }
 }


 public void backClick(View v){
    finish(); 
 }

}

my food menu interface foods.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>
<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>

<Button  
        android:layout_height="wrap_content"  
        android:text="Back"  
        android:onClick="backClick"  
        android:layout_width="fill_parent">  
</Button> 

my list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
    <ImageView  android:id="@+id/img"
                android:scaleType="centerCrop"
                android:layout_width="100dp"
                android:layout_height="100dp"/>
    <LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"
                    android:orientation="vertical"
                    android:paddingLeft="10dp"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content">
        <TextView
            android:layout_width="fill_parent"
            android:id="@+id/title"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:textColor="#ffffff"
            android:textSize="16sp" />
        <TextView
            android:layout_width="fill_parent"
            android:id="@+id/detail"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"/>

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/quantity"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Quantity :"
                android:textColor="#ffffff" />

            <EditText
                android:id="@+id/quantityInput"
                android:layout_width="wrap_content"
                android:layout_height="35dp"
                android:layout_toRightOf="@id/quantity"
                android:hint="1-10"
                android:paddingLeft="10dp"
                android:textSize="12dp" />

            <Button
                android:id="@+id/order"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="120dp"
                android:layout_toRightOf="@id/quantity"
                android:onClick="orderClick"
                android:text="Order"
                android:textSize="12dp" />

        </RelativeLayout>
    </LinearLayout>

  • 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-27T06:11:47+00:00Added an answer on May 27, 2026 at 6:11 am

    I’m at school now so I don’t have time to get a you a code snippet at all but you are going to need to use startActivityForResult() instead of just startActivity(). This will allow you to send information back to your main app upon completion of the your food activity.

    Respond if you need me to find a snippet for you and I’ll write one up quick once I get home in about an hour.

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

Sidebar

Related Questions

Thanks for reading this. I am dynamically generating some data which includes a select
Thanks for reading this. I have markup similar to what is below. Using the
Thanks for reading this I thought I could use find(), but couldn't make it
Thanks for reading this. I would have thought it would be as simple as
Thanks in Advance for reading and answer this question. I got button in asp
I'm reading about Rails fixtures in this guide (thanks, trevorturk). It appears you define
Thanks for reading. I'm a bit new to jQuery, and am trying to make
and thanks for reading. I am building a data entry form. I am trying
to all im newbie developer and trying to create my first iPhone app, sorry
Thanks for reading! I am building a custom Gallery app where the first thumbnail

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.