1

我想知道是否可以使用 webview 打开另一个类,我在我的应用程序中使用了此代码,但它让我只探索图像请帮助我,谢谢。这是代码:

WebView  imageView1n;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imageView1n=(WebView)findViewById(R.id.imageView1n);
        imageView1n.setWebViewClient(new WebViewClient());
         WebSettings webSettings = imageView1n.getSettings();
         webSettings.setLoadWithOverviewMode(true);
         webSettings.setUseWideViewPort(true);
         imageView1n.loadUrl("http://bitsparrow.altervista.org/wp-content/uploads/2013/04/5.jpg");



       Button button1=(Button) findViewById(R.id.Bopenbx);


       imageView1n.setOnClickListener(new WebView.OnClickListener() {
           public void onClick(View v){
               Intent myIntentActivity1 = new Intent(menu.this,N_X.class);
               //call N_X and wait for result
               startActivity(myIntentActivity1);






        }
    });
4

1 回答 1

1

尝试使用 setOnTouchListener 而不是 setOnClickListener 打开 WebView 上的下一个 Activity 单击:

imageView1n.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if(event.getAction() == MotionEvent.ACTION_UP){

            Intent myIntentActivity1 = new Intent(menu.this,N_X.class);
            //call N_X and wait for result
            startActivity(myIntentActivity1);

            return true;
        }
        return false;
    }
});
于 2013-05-28T20:13:35.937 回答