0

私はこのレイアウトを持っています:

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

    <com.ui.library.actionbar.ActionBar
        android:id="@+id/actionBar1"
        style="@style/ActionBar"
        android:layout_width="wrap_content"
        android:layout_height="48dip"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />

    <com.cidaut.moveo.calendar.ui.calendar.SingleCalendar
        android:id="@+id/singleCalendar1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/view1"
        android:layout_below="@+id/actionBar1" />

    <RelativeLayout
        android:id="@+id/view1"
        android:layout_width="match_parent"
        android:layout_height="48dip"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:background="@color/dark_gray" >

        <Button
            android:id="@+id/buttonFiltros"
            style="@style/MetroButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:padding="8dip"
            android:text="@string/filter" />
    </RelativeLayout>

</RelativeLayout>

すべてが期待どおりに機能します。ただし、を検索するために呼び出した場合、findViewByIdnullが返されます。ActivityR.id.singleCalendar1

私は無駄に掃除と更新を試みました。

を使用してビューを膨らませ、LayoutInflater.from(this).inflate(R.id.calendar_layout, null)その子を見つけてから、singleCalendar1IDを見つけることを考えました...

-1!

私は本当に何をすべきかわかりません。後知恵は大歓迎です。

4

2 に答える 2

4

私はここで何が起こっているのか考えていると思います...多分それはあなたと一緒に効果的なダイアログの一部ですか?

このようなものを想定してください

 Dialog d = new Dialog(this);
 setContentView(R.layout.my_layout);
 findViewById(R.id.my_view); //doesn't work

これを試して

 Dialog d = new Dialog(this);
 setContentView(R.layout.my_layout);
 View v = (View) d.findViewById(R.id.my_view); //will work

親から参照してみてください。または、このレイアウトがプルイン/使用されているコードをさらに投稿してください。

また、単一のカレンダーオブジェクト用の適切なコンストラクターはありますか?

これが必要です

AndroidObject(Context context, AttribSet attrs);

これはsuper(context、attrs);を呼び出します。

多分それはそれを修正します。

于 2012-10-16T12:38:20.033 に答える
0


膨らませるには、このコードを使用してください

LayoutInflater inflaterLayoutInflater=(LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout=inflaterLayoutInflater.inflate(R.id.calendar_layout,null);


それ以外の場合は、天気を確認してください。通常使用している場合は、setCOntentViewで正しいレイアウトが設定されています。

于 2012-10-16T12:39:24.807 に答える