-8

このチュートリアル「サブサンプリング スケール イメージ ビュー」のコードをテストしてズーム イメージ ピンチを作成しようとしていますが、.findViewById(id. imageView );で 1 つのエラーが発生します。-シンボルを解決できません..

私のXMLレイアウト:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>

そして私のMainActivityフラグメントコードには、このコードがあります(onCreateメソッド内):

public class MainActivity extends AppCompatActivity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(id.imageView);
        imageView.setImage(ImageSource.resource(R.drawable.abc));

    }
}

誰でも私を助けてくれませんか?

よろしくお願いします

4

2 に答える 2

-1
 SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(R.id.imageView);
        imageView.setImage(ImageSource.resource(R.drawable.abc));

あなたは逃したR.id.imageView

于 2016-09-28T17:32:00.403 に答える
-4

簡単な解決策:に置き換えid.imageViewますR.id.imageView

ID を参照したい場合は、Randroid が提供する (Resources) ディレクトリに移動します。リソース ディレクトリ ( R) に移動する必要があり、そこにidディレクトリがあります。次に、あなたのIDです。したがって、最終結果はR.id.imageViewです。

于 2016-09-28T17:31:39.193 に答える