좋아, 여기에는 아주 복잡한 설정이 있습니다. 내 주요 활동은 TabHost
이며 그 중 하나의 탭에는 텍스트, 버튼, ListView
이 표시됩니다. 어떤 이유로 든 ListView
에는 1 개의 항목 만 표시됩니다. 항목을 더 추가하면 목록의 첫 번째 항목 만 표시됩니다.TabHost의 활동에서 ListView
tabmenu.xml :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:configChanges="orientation|keyboardHidden|screenSize">
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:scrollbarStyle="outsideInset"
android:scrollbars="horizontal"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<include layout="@layout/main"/>
<include layout="@layout/scheduler"/>
</FrameLayout>
</LinearLayout>
</TabHost>
</ScrollView>
Scheduler.xml : (목록보기는 곳입니다)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/schedulerLayout">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentTop ="true"
android:gravity="center"
android:paddingBottom="20dp"
android:id="@+id/timeLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/currentHours"
android:textSize="50dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50dp"
android:text=":"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/currentMinutes"
android:textSize="50dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ampm"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/currentDayOfWeek"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/currentDate"/>
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/scheduleButton"
android:text="@string/newSchedule"
android:layout_below="@id/timeLayout"/>
<!--android:enabled="false"-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/scheduleButton"
android:paddingTop="5dp"
android:orientation="vertical">
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#FFFFFFFF"/>
<ListView
android:id="@+id/scheduler_list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<!-- android:focusable="false"
android:focusableInTouchMode="false"-->
</LinearLayout>
</RelativeLayout>
Main.java :
//adds tabs to view
spec = tabHost.newTabSpec("Auto Respond")
.setIndicator(" Auto Respond ")
.setContent(R.id.mainLayout);
tabHost.addTab(spec);
spec = tabHost.newTabSpec("Scheduler")
.setIndicator(" Scheduler ")
.setContent(R.id.schedulerLayout);
tabHost.addTab(spec);
tabHost.getTabWidget();
//start setup of list display
int number = 0;
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>();
HashMap<String, Object> row = new HashMap<String, Object>();
//gets number of items, gets title, startTime, etc. here (lots of code, so I cut it out)
if(curTitle != null && !curTitle.equals(""))
{
row = new HashMap<String, Object>();
row.put("Title", curTitle);
row.put("Time", time);
row.put("Day", dayText);
row.put("Month", monthText);
data.add(row);
}
//create list
SimpleAdapter adapter = new SimpleAdapter(this,
data,
R.layout.schedulerow,
new String[] {"Title","Time","Day", "Month"},
new int[] { R.id.scheduleListTitle, R.id.scheduleListTime,R.id.scheduleListDays, R.id.scheduleListMonths});
listview.setAdapter(adapter);
어떤 아이디어로 왜 내 ListView
의 첫 번째 항목 만 표시합니까? 나는 단순히 Activity
을 ListActivity
으로 변경하려고 시도했고 FC로 보냈다. 가능하다면 으로 작동하도록 코드를 모두 다시 만들고 싶지 않으므로 가능한 한 Activity
으로 유지하고 싶습니다.
'데이터'에 두 개 이상의 항목이 있음을 확인 했습니까? 항목을 추가 할 때'notifyDataSetChanged()'를 사용합니까? – Sam
'data'와'adapter'는 모두 2 가지 항목을 가지고 있다는 것을 확인했습니다. 나는 notifyDataSetChanged()를 사용하지 않는다. 나는 지금 막 시도하고, 도움이되지 않았다. – Randy
많은 정보를 표시하려고하고 있으며 ListView를 ScrollView에 중첩했습니다. ListView를 보려면 스크롤해야합니까? 그렇다면 ListView가 스크롤 동작을 방해하는 제스처를 사용하여 전체 ListView를 볼 수 없도록합니다. – Sam