Android 我想在ListView中排列ArrayList值

Android 我想在ListView中排列ArrayList值,android,arraylist,tablelayout,Android,Arraylist,Tablelayout,我正在处理ArrayList。我想在ListView中显示ArrayList,我不知道如何在ListView中使用ArrayList 在这幅图中,“计算机科学”是一门学科,它应该属于子学科,其他价值观也属于每一个学科 //布局 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:background

我正在处理ArrayList。我想在ListView中显示ArrayList,我不知道如何在ListView中使用ArrayList

在这幅图中,“计算机科学”是一门学科,它应该属于子学科,其他价值观也属于每一个学科

//布局

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:background="@drawable/login"
android:layout_height="fill_parent"
android:orientation="vertical" >

  <LinearLayout android:layout_weight="1" android:layout_height="fill_parent"   android:layout_width="fill_parent"
  android:layout_marginTop="175dp" android:orientation="horizontal" android:background="@android:color/darker_gray"
  android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginBottom="20dp">

  <TextView android:layout_width="wrap_content" android:layout_height="match_parent" 
    android:textSize="16dp" android:text="Sub" android:layout_marginLeft="5dp"/>

  <TextView android:layout_width="wrap_content" android:layout_height="match_parent" 
      android:textSize="16dp" android:text="Mon" android:layout_marginLeft="20dp"/>

  <TextView android:layout_width="wrap_content" android:layout_height="match_parent" 
      android:textSize="16dp" android:text="Tue" android:layout_marginLeft="23dp"/>

  <TextView android:layout_width="wrap_content" android:layout_height="match_parent" 
      android:textSize="16dp" android:text="Wed" android:layout_marginLeft="23dp"/>

  <TextView android:layout_width="wrap_content" android:layout_height="match_parent"
       android:textSize="16dp" android:text="Thu" android:layout_marginLeft="23dp"/>
  <TextView android:layout_width="wrap_content" android:layout_height="match_parent"
       android:textSize="16dp" android:text="Fri" android:layout_marginLeft="23dp"    android:layout_marginRight="2dp"/>

          </LinearLayout>
      <LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent" 
  android:layout_marginLeft="5dp">

     <ListView android:layout_height="match_parent"  android:layout_width="match_parent" android:id="@+id/getAttdnce_lv">

    </ListView>

   </LinearLayout>


</LinearLayout>

公共类MainActivity扩展活动{
公共静态最终字符串[]主题=新字符串[]{“数学”、“计算机”、“英语”};
私有ListView lv;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv=(ListView)findViewById(R.id.listView1);
ArrayAdapter=新的ArrayAdapter(MainActivity.this,android.R.layout.simple\u list\u item\u 1,主题);
低压设置适配器(适配器);
}
}

尝试使用TableLayout,然后根据需要动态创建行。

尝试使用网格布局。我认为它更适合你的设计。并检查
列span
属性。你不在布局中应用css吗?发布你的布局,我只想排列这些值。我不需要使用css@ShahidBangash发布xml文件。我必须连续调用arraylist,arraylist将返回多个值,这些值将显示在单个单元格中,这对我来说是个问题。我不想在单个单元格中显示这些值,我想在特定的单元格中显示这些值。@shahibangash您可以创建任意数量的单元格。添加与arraylist大小相等的标记,并添加的子项。每个子项将被视为一列。在代码中完成这一切,只需用xml定义即可。这里有一个基本的例子,你所说的标签是什么意思?@shahibangash TableLayout是一个可以在布局文件中使用的xml标签。现在,在代码中,循环遍历arraylist,并为每个项按new TableRow创建一个TableRow(如下所示)。现在,对于每个要添加为列的值,调用tablerow.addView(newtextView(this).setText(“Test”)),最后调用tableLayout.addView(tablerow)。现在清楚了吗?兄弟,这是另外一回事,在行中创建列很容易,但我调用arraylist。如果您有代码,请与我共享。
public class MainActivity extends Activity {
     public static final String[] Subject = new String[] { "Maths","Computer", "english"};
    private ListView lv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lv=(ListView)findViewById(R.id.listView1);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this,  android.R.layout.simple_list_item_1, Subject);
        lv.setAdapter(adapter);
    }


}