Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从ListView中激活的意图活动和按钮获取数据_Android_Button_Android Intent_Android Activity - Fatal编程技术网

Android 如何从ListView中激活的意图活动和按钮获取数据

Android 如何从ListView中激活的意图活动和按钮获取数据,android,button,android-intent,android-activity,Android,Button,Android Intent,Android Activity,您好,谢谢您的阅读!请帮帮我 我正在尝试创建一个餐馆应用程序,其中显示菜单中的3个按钮,然后单击显示食物列表的食物按钮,然后客户可以选择他们想要点的食物,然后将订单发送回第一页。我读了很多文章,有人说使用listview.setItemsCanFocus(true),但我在理解它以实现它时遇到了问题。有些人说按钮监听器在getView中,但当我实现我的程序时,它就挂起了。请帮帮我。多谢各位 我的菜单: 这是我的食物(第二页) 我有问题: 将所选数据数组(食品订单)从food.class传输回

您好,谢谢您的阅读!请帮帮我

我正在尝试创建一个餐馆应用程序,其中显示菜单中的3个按钮,然后单击显示食物列表的食物按钮,然后客户可以选择他们想要点的食物,然后将订单发送回第一页。我读了很多文章,有人说使用listview.setItemsCanFocus(true),但我在理解它以实现它时遇到了问题。有些人说按钮监听器在getView中,但当我实现我的程序时,它就挂起了。请帮帮我。多谢各位

我的菜单:

这是我的食物(第二页)

我有问题:

  • 将所选数据数组(食品订单)从food.class传输回我的主类restaurant.class

  • 在列表中添加按钮后,食物不可点击(整行食物)

  • 单击要放大的图像和其他位置(除图像外,将其关闭)

  • 我的主课(餐厅)

    }

    我的第二节课(食品课)

    package com.restaurant.sesame;
    公营食物活动{
    私人停车场;
    专用矢量数据;
    罗维达路;;
    静态最终字符串[]标题=新字符串[]{
    “牛肋排”,
    “泰国虾炒饭”,
    “圣诞快乐”,
    "三文鱼排";;
    静态最终字符串[]详细信息=新字符串[]{
    “1小时3700万运费:10.00美元”,
    “1小时39m配送:免费”,
    “5800万6s运费:10.00美元”,
    “5900万30年代航运:10.95美元”;
    私有整数[]imgid={R.drawable.food1,R.drawable.food2,R.drawable.food3,R.drawable.food4};
    创建时的公共void(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.foods);
    mInflater=(LayoutInflater)getSystemService(
    活动。布局(充气机和服务);
    数据=新向量();
    
    对于(int i=0;i要将数据传回,您可以通过以下方式启动food.class活动:

    startActivityForResult();
    
    使用以下方法将数据放回目标中:

    getIntent().putExtra()
    
    至于ListView中项目不可点击的问题……有很多“答案”,但最简单的是在每一行中设置所有小部件,以使属性

    android:focusable="false" android:focusableInTouchMode="false"
    

    更多信息可在以下位置获得:在标题为“开始活动并获得结果”的顶部部分下,我不知道应该将android:focusable=“false”android:focusableInTouchMode=“false”放在哪里?行布局中每个小部件的XML。如果我添加到所有小部件(是否需要包括Linearlayout?),我的编辑文本变得不可编辑,我的按钮也不可点击。
    <?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>
    
    startActivityForResult();
    
    getIntent().putExtra()
    
    android:focusable="false" android:focusableInTouchMode="false"