Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.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 一个XML中有多个ListView。可能吗?_Android_Android Layout_Android Listview_Android 3.0 Honeycomb - Fatal编程技术网

Android 一个XML中有多个ListView。可能吗?

Android 一个XML中有多个ListView。可能吗?,android,android-layout,android-listview,android-3.0-honeycomb,Android,Android Layout,Android Listview,Android 3.0 Honeycomb,我想显示多个并排(水平)的列表视图,每个视图都可以自己滚动,其中一个视图的滚动不会改变其他视图的滚动位置,也可以扩展它,而不是Android的常规复选按钮,我想使用我的图像 我这里用蜂巢 这是我想要的示例屏幕截图 如能为我提供任何帮助,我将不胜感激。 这是我的视图xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android

我想显示多个并排(水平)的列表视图,每个视图都可以自己滚动,其中一个视图的滚动不会改变其他视图的滚动位置,也可以扩展它,而不是Android的常规复选按钮,我想使用我的图像

我这里用蜂巢

这是我想要的示例屏幕截图

如能为我提供任何帮助,我将不胜感激。 这是我的视图xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:splitMotionEvents="true">
    <ListView android:id="@+id/list1" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" />
    <ListView android:id="@+id/list2" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" />
    <ListView android:id="@+id/list3" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" />
</LinearLayout>

Java代码:

public class DesignMain extends Activity {
/** Called when the activity is first created. */
LazyAdapter dealAdapter;
static ViewHolder holder;
ListView list,list1,list2;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    list=(ListView)findViewById(R.id.userdeal);
    list1=(ListView)findViewById(R.id.userdeal1);
    list2=(ListView)findViewById(R.id.userdeal2);
    dealAdapter = new LazyAdapter(DesignMain.this,sCheeseStrings);
    list.setAdapter(dealAdapter);
    list1.setAdapter(dealAdapter);
    list2.setAdapter(dealAdapter);
}
class LazyAdapter extends BaseAdapter {
    LayoutInflater mInflater;       
    String name;
    String TAG = "MultiLine";
    int i = -1;
    int j = -1;
    int k = -1;
    String[] VAL1,VAL2,VAL3,VAL4,VAL5,VAL6,VAL7;

    public LazyAdapter(Context context, String[] value1) {
        try {
            mInflater = LayoutInflater.from(context);
            VAL1 = value1;
        } catch (Exception e) {
            Log.v(TAG, "dom" + e);
        }
    }
    public int getCount() {
        return VAL1.length;
    }
    public Object getItem(int arg0) {
        return arg0;
    }
    public long getItemId(int arg0) {
        return arg0;
    }
    public View getView(int position, View convertView, ViewGroup arg2) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.list, null);
        holder = new ViewHolder();
        holder.text1 = (TextView) convertView.findViewById(R.id.listtext);
        convertView.setTag(holder);
    } else {
        holder.text1 = (TextView) convertView.findViewById(R.id.listtext);
    }
    holder.text1.setText(VAL1[position]);
    return convertView;
} 
}
static class ViewHolder {
    TextView text1, text2, text3,text4,text_time;
    ImageView icon;
}
static final String[] sCheeseStrings = {"Hushallsost", "Iberico", "Idaho Goatster",
    "Idiazabal", "Il Boschetto al Tartufo", "Ile d'Yeu", "Isle of Mull", "Jarlsberg",
    "Jermi Tortes", "Jibneh Arabieh", "Jindi Brie", "Jubilee Blue", "Juustoleipa",
    "Kadchgall", "Kaseri", "Kashta", "Kefalotyri"
    };
static final String[] sCheeseStrings1 = {"Cabecou", "Caboc", "Cabrales", "Cachaille", "Caciocavallo", "Caciotta",
    "Caerphilly", "Cairnsmore", "Calenzana", "Cambazola", "Camembert de Normandie",
    "Canadian Cheddar", "Canestrato", "Cantal", "Caprice des Dieux", "Capricorn Goat",
    "Capriole Banon", "Carre de l'Est", "Casciotta di Urbino", "Cashel Blue", "Castellano"
    };
static final String[] sCheeseStrings2 = {"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi",
    "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale",
    "Aisy Cendre", "Allgauer Emmentaler", "Alverca", "Ambert", "American Cheese",
    "Ami du Chambertin", "Anejo Enchilado", "Anneau du Vic-Bilh", "Anthoriro", "Appenzell"
    };
}

Main.xml

<LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"  android:layout_width="wrap_content" 
                android:layout_height="fill_parent">
    <LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"
                    android:orientation="horizontal"
                    android:layout_width="wrap_content" android:layout_height="fill_parent">
    <ListView       android:id="@+id/userdeal" android:listSelector="@drawable/list1" 
                    android:cacheColorHint="#00000000" android:layout_width="120dip" 
                    android:layout_height="fill_parent" />      
    <ListView       android:id="@+id/userdeal1" android:listSelector="@drawable/list1" 
                    android:cacheColorHint="#00000000" android:layout_width="100dip" 
                    android:layout_height="fill_parent" />     
    <ListView       android:id="@+id/userdeal2" android:listSelector="@drawable/list1" 
                    android:cacheColorHint="#00000000" android:layout_width="100dip" 
                    android:layout_height="fill_parent" />       
</LinearLayout>

List.xml:

<LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical" android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:layout_marginLeft="10dip" android:id="@+id/lay_txt">
   <TextView    android:id="@+id/listtext" android:textSize="15sp"
                android:textColor="#FFFFFF"
                android:layout_width="wrap_content" android:layout_height="20dip"
                android:ellipsize="end" android:layout_marginTop="15dip" android:text="Card No" />
  <RadioButton  android:id="@+id/select_card" android:layout_width="wrap_content" 
                android:layout_height="wrap_content"  android:layout_alignParentRight="true"
                android:focusable="false"/>
</RelativeLayout>


哪个部件不工作?(顺便说一句,您可能不希望LinearLayouts包装列表视图的高度包含包装内容。)BaseAdapter只填充第一个列表,第二个和第三个列表为空。您可以发布一些代码吗?特别是为每个列表和适配器实现构造和设置适配器的位置。我就是无法理解getView方法的头绪。没有比这更简单的了。谢谢。@Sana你有你想要的设计吗?是的,我有。回答得很好,文卡特什。谢谢。。我们可以通过聊天分享GTalk中的知识。。你能?