这是布局xml
<ListView
android:id="@+id/titleListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
我的活动是:
public class DummyActivity extends Activity {
private ListView titleListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_assignment);
titleListView=(ListView)findViewById(R.id.titleListView);
showAssignmentTitlesInList();
}
private void showAssignmentTitlesInList()
{
String[] monthsArray = { "JAN", "FEB", "MAR", "APR", "MAY", "JUNE", "JULY",
"AUG", "SEPT", "OCT", "NOV", "DEC" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(DummyActivity.this,
android.R.layout.simple_list_item_1 ,monthsArray);
titleListView.setAdapter(adapter);
Log.d("TAG", monthsArray.length+"");
}
}
这是我的数组数组适配器代码...
我有一个名为“Months array”的字符串数组,我需要将其显示为列表视图。