1

ビューを ScrollImageView に拡張しました。次に、それをxmlに入れます:

main.xml で:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content" android:layout_width="wrap_content"
    android:orientation="vertical">
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="@string/hello" />

    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:id="@+id/my_xml" />

    <com.Android.Maps03.ScrollImageView
        android:id="@+id/BaseView" android:layout_width="fill_parent"
        android:layout_height="fill_parent" />



</RelativeLayout>

次に、次のようなメインアクティビティでそれを使用したいと思います:

 public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        ScrollImageView sIV = (ScrollImageView)findViewById(R.id.BaseView);
        Bitmap markerImage = BitmapFactory.decodeResource(this.getResources(), R.drawable.mapbase );
        sIV.setImage(markerImage);

アプリを実行すると、ScrollImage が表示されません。

クラス (ScrollImageView) のコンストラクターは次のとおりです。

public ScrollImageView(Context context, AttributeSet attributeSet) {
    super(context);
    initScrollImageView(context);

private void initScrollImageView(Context context) {
    mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    mPadding = DEFAULT_PADDING;
}

アイデアはありますか?

ありがとう。

コメント #1 はい、忘れましたが、同じ問題があります。

コメント #2 いいえ、2 番目の /> ですべてのレイアウトを閉じます。2 回閉じません

コメント #3 これは新しい logcat です。これは最も注目すべきエントリだと思います。

助けてください!

4

1 に答える 1

1

Activity onCreate で setContentView を呼び出していません

于 2011-03-14T21:54:10.400 に答える