スクロール可能なハイスコアリストを作成しようとすると、次のようになります。
foo 1000
bar 876
foobar 500
foobarfoo 1
私は現在GridViewでそれをやっています。名前列の幅を画面の 60%、スコア列の幅を 40% に設定したいと思います。出来ますか?
現在、costum アダプター経由で試しています。そのための getview 関数は次のとおりです。
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv;
if (convertView == null) {
tv = new TextView(context);
tv.setTextSize(25);
tv.setTextColor(Color.WHITE);
if (position % 2 == 0)
{
tv.setLayoutParams(new GridView.LayoutParams((width/10)*6, 50));
}
else
{
tv.setLayoutParams(new GridView.LayoutParams((width/10)*4, 50));
}
}
else {
tv = (TextView) convertView;
}
tv.setText(texts[position]);
return tv;
}
レイアウトは、グリッドビューと下部のボタンによって構築されます。XML ファイルは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/top">
<GridView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:id="@+id/grid"
android:numColumns="2"
android:columnWidth="0dp"
>
</GridView>
<Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/backbutton" android:text="@string/backstr"></Button>
</LinearLayout>
もう一度質問します。異なるサイズの列を追加できるように GridView を設定することは可能ですか? はいの場合、私のアプローチは良いですか?(動作していないため、おそらくそうではありません:)) 何か見逃したのですか?
前もって感謝します!