2
XMLからのカスタムビューを作成したい。xmlからカスタムビューを作成する
は、ここに私のXMLです:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/movieTitle"
android:text="@string/movietitle"
android:textSize="35dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
/>
<com.galite.headliner.views.LoaderImageView
android:id="@+id/moviePoster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/movieTitle"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:contentDescription="@string/poster"
/>
<TextView
android:id="@+id/movieDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/description"
android:layout_below="@id/moviePoster"
android:gravity="center"
/>
</RelativeLayout>
と私はonClickの、すべてのようなメソッドを使用する必要があるため、カスタムビューに膨張するようにしたいです。ここで
は私のコンストラクタです:
public MyView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context = context;
initializeView();
}
public void initializeView(){
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.movie, null);
}
私はVにMYVIEWを等しくすることができますどのように?
LayoutInflater型のinflate(int、ViewGroup、boolean)メソッドが引数に適用されません(int、MovieView、boolean) – Tsunaze
@Tsunaze申し訳ありませんが、私は自分の答えを編集しました。 – Luksprog