0

日曜日に、私は実際に最初のアプリをサイドロードしました!!! シンプルで未完成のいくつかのバグですが、動作します。

私の開始画面 (XML: "event_list.xml") はスクロール リストです - 詳細取得画面を 1 つ選択します。XML は次のようになります: (このコードはまだフラグメントです。)

  <?xml version="1.0" encoding="utf-8"?>
  <fragment 
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:name="com.dummies.android.taskreminder.EventListFragment"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" />

行 (XML "event_row.xml") は次のようになります。

  <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/text1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:textSize="12dp"
        android:padding="2dip" />

スクロールの上の上部にいくつかのボタンが必要です。私ができる最善のことは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<fragment 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:name="com.dummies.android.taskreminder.EventListFragment"
        android:layout_width="fill_parent"
android:layout_height="fill_parent" >
      <Button
          android:id="@+id/btn_Add"
          android:text="@string/add"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />
  </fragment>   

しかし、ボタンは最初のエントリをオーバーレイします! 行をリスト画面に結び付けるものと、スクロール (行) の上に 2 つのボタンを表示するにはどうすればよいですか?

4

1 に答える 1

0

これが最終的に機能したものです。

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

 <Button  android:id="@+id/btn_Add"
    android:layout_width="50dp"
    android:layout_height="30dp"   
    android:textSize="12dp"
    android:padding="1dip"
    android:text="@string/add" />

  <Button  android:id="@+id/btn_Exit"
    android:layout_width="50dp"
    android:layout_height="30dp"
    android:textSize="12dp"
    android:padding="1dip"
    android:layout_marginLeft="5dp"
    android:layout_toRightOf="@+id/btn_Add" 
    android:text="@string/exit" />

  <Button  android:id="@+id/btn_Other"
    android:layout_width="50dp"
    android:layout_height="30dp"
    android:textSize="12dp"
    android:padding="1dip"
    android:layout_marginLeft="5dp"
    android:layout_toRightOf="@+id/btn_Exit" 
    android:text="@string/other" />

 <fragment
    android:name="com.dummies.android.taskreminder.EventListFragment"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/btn_Add"  />
 </RelativeLayout>   

   <TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/text1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:textSize="12dp"
    android:padding="2dip" />
<!-- This defines a row in which text can be placed -->
<!--   "text1" is the IDof the view for loading the list with data -->

ここで、詳細画面 (アクティビティのみ) からコピーしたボタン コードをリスト画面 (フラグメントあり) で機能させる必要があります。これにより、エラーが発生します: (findViewById undefined)

  mExitButton = (Button)findViewById(R.id.btn_Exit);

これはクラッシュしました:

  mExitButton = (Button)getView().findViewById(R.id.btn_Exit);

これでまだ作業中です(遅いです):

   View myFragmentView = inflater.inflate(R.layout.????????, container, false);
于 2013-04-17T10:32:09.243 に答える