0

アクティビティのビューとしてタブがあります。各タブはを表しますListView。さらに明確にするために、 sにはsが膨らんListViewでいません。TextViewxmlスキーマにはテキスト属性がないためListView、アクティビティ内でそれを実行できるかどうか疑問に思いました。そうでない場合、あなたは何を提案しますか?

レイアウトファイル:tabworkentry.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout
    android:id="@+id/tablayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <!-- Include action bar -->
<include layout="@layout/actionbar_layout"/>

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"

        android:background="@drawable/innerdashboard_bg"
        android:layout_weight="1">

        <!-- Top 10 starts -->

            <ListView 
            android:id="@+id/Top_10"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:paddingRight="5dp" 
            android:text="this is a tab" />

        <!-- Top 10 ends -->

        <!-- Billable starts -->
        <ListView 
            android:id="@+id/Billable"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:paddingRight="5dp" 
            android:text="this is another tab" />

        <!-- Billable ends -->

        <!-- Product starts -->
        <ListView
            android:id="@+id/Product"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:paddingRight="5dp"
            android:textSize="14sp"
            android:text="this is a third tab" />

        <!-- Product ends -->

     </LinearLayout>
</TabHost>

そしてJavaコード:

protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    try {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabworkentry);

TabHost  mTabHost = getTabHost();

 mTabHost.addTab(mTabHost.newTabSpec("top10").setIndicator("Top  10").setContent(R.id.Top_10));
          mTabHost.addTab(mTabHost.newTabSpec("billable").setIndicator("Billable").setContent(R.id.Billable));
     mTabHost.addTab(mTabHost.newTabSpec("product").setIndicator("Product").setContent(R.id.Product));

  mListView = (ListView)findViewById(R.id.Top_10);
  mListView.setAdapter(new ArrayAdapter<String>(this,
  android.R.layout.simple_list_item_1,Top_10));   

  mListView = (ListView)findViewById(R.id.Billable);
  mListView.setAdapter(new ArrayAdapter<String>(this,
  android.R.layout.simple_list_item_1,Billable));

 mListView = (ListView)findViewById(R.id.Product);
 mListView.setAdapter(new ArrayAdapter<String>(this,
 android.R.layout.simple_list_item_1,Product));


    } catch (Exception e) {
        System.out.println("Exception" + e.getStackTrace());
        Log.d(TAG, "Exception" + e.getStackTrace());
    }
}  
4

3 に答える 3

4

独自の行レイアウトを作成し、TextView を追加する必要があります。その後、Text フォントを設定できます...

カスタムレイアウトを使用すると、それを行うことができます...

とても膨らむ R.layout.row

行.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp" android:typeface="serif"
    android:textSize="15dp" >
</TextView>
于 2012-06-22T13:53:19.490 に答える
1

あなたのアプローチではできません、それは不可能です。ただし、たとえばBaseAdapterそれから拡張する独自のクラスを作成する場合、メソッドでテキストの外観を変更することはできませんgetView()が、それでも必要ですTextView

ノート:

  1. row.xmlcontains を使用して独自のものを作成するだけTextViewです。
  2. BaseAdapter通話中にフォント (色、サイズなど) を使用および変更しますgetView()


あなたのrow.xml缶は次のようになります:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>


注 2:
ここでも書体を設定できますが、可能なオプションは 3 つだけです (モノスペース、セリフ、サン)。

于 2012-06-22T13:54:19.477 に答える
1
new ArrayAdapter<String>(this,
  android.R.layout.simple_list_item_1,Billable){

@Override
        public View getView(int position, View convertView, ViewGroup parent) {

               convertView= super.getView();

                TextView text = (TextView) convertView.findViewById(android.R.id.text1);


                return convertView;
        }

}
于 2012-06-22T13:55:02.850 に答える