Gioele
Gioele

Reputation: 83

open another class with webview

I want to know if it was possible to open another class with the webview, I used this code in my app but it makes me explore only the image please help me thanks. this is the code:

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);






        }
    });

Upvotes: 1

Views: 110

Answers (1)

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132992

try it as to open next Activity on WebView click using setOnTouchListener instead setOnClickListener:

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;
    }
});

Upvotes: 1

Related Questions