私はスクロールビューで2つのリストビューが必要ですが、これは明らかにAndroidでは不可能ですが、これは顧客が必要とするものです。だから私はプログラム的に私のリストを膨らませようとしている。私のテーブルセルは私の現在のセットアップでは表示されません。私がxmlファイルの設定を調整すると、上の行が表示されますが、他の行は表示されません。私はここで間違って何をしていますか?Androidプログラムリストを作成
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.alertsview);
inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
topRows = new ArrayList<View>();
topLayout = (LinearLayout)findViewById(R.id.topListLayout);
bottomRows = new ArrayList<View>();
bottomLayout = (LinearLayout)findViewById(R.id.bottomListLayout);
addRecip = (Button) findViewById(R.id.addRecipient);
addRecip.setOnClickListener(this);
if (SugarLoafContext.currentSite.alertRecipients.size() >= 5)
addRecip.setVisibility(View.GONE);
else
addRecip.setVisibility(View.VISIBLE);
EventBus.subscribe(ConfigureAlertsNotification.class, this);
EventBus.publish(new ViewAlertsNotification());
}
public void setTopList()
{
topLayout.removeAllViews();
topRows.clear();
List<Camera> camList = new ArrayList<Camera>(SitesOrchestrator.getInstance().currentSite.cameraList);
for (int i = 0; i < camList.size(); i++)
{
String index = Integer.toString(i);
Camera cam = camList.get(i);
View row = inflater.inflate(R.layout.cameraalertrow, null);
TextView name = (TextView)row.findViewById(R.id.cameraNameAlerts);
CheckBox chk = (CheckBox)row.findViewById(R.id.camAlertChk);
name.setText(cam.name);
name.setTextColor(Color.GRAY);
chk.setOnCheckedChangeListener(this);
chk.setTag(index);
if (cam.isOnline)
{
chk.setEnabled(true);
if (cam.alertsEnabled && !chk.isChecked())
chk.setChecked(true);
else if (cam.alertsEnabled == false && chk.isChecked())
chk.setChecked(false);
}
else
{
chk.setChecked(cam.alertsEnabled);
chk.setEnabled(false);
name.setTextColor(Color.DKGRAY);
}
topRows.add(row);
topLayout.addView(row);
}
}
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:fillViewport="true"
android:id="@+id/alertsTopScroll">
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TextView
android:id="@+id/alertsTopText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:text="@string/alerts_top_title"
android:gravity="center"
android:textColor="#000000"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
</TextView>
<LinearLayout
android:id="@+id/topListLayout"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</LinearLayout>
<TextView
android:id="@+id/alertsBottomText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:text="@string/alerts_bottom_title"
android:gravity="center"
android:textColor="#000000"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
</TextView>
<LinearLayout
android:id="@+id/bottomListLayout"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</LinearLayout>
<Button
android:id="@+id/addRecipient"
android:layout_height="50dp"
android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
android:text="@string/addRecipient"/>
</LinearLayout>
</ScrollView>
(とはい方法setTopList()と呼ばれている)
ええ、あなたはクライアントが望んでいることを説明できますか?彼らは何を見たいのですか? – Estel
これは、テキストビュー、次にアイテムのリスト、次に別のテキストビュー、次にアイテムの別のリスト、そしてボタンを表示します。項目のリストを完全に展開し、画面全体をスクロール可能にする必要があります。いずれにしてもAndroidの制限を超え、各リストビューの行の高さを計算し、各リストビューをその高さに拡張し、スクロールビューでうまく動作します。 – spentak
高さを絶対に設定しましたか?つまり、pxまたはdipですか?あなたはtextviewsがすべてのデバイスのequealの高さを持っていると確信していますか?異なる画面解像度では、改行数が異なります。異なるデバイスでは、高さの異なるフォントが異なる場合があります。 – thaussma