如何使用户按下图像按钮并在不打开新窗口的情况下按下URL链接?
private class HandleClick implements View.OnClickListener {
public void onClick(View arg0) {
if(arg0.getId()==R.id.imageButton){
((TextView) findViewById(R.id.textView2)).setText("Pressed: " + ++howManyClicks1);
Uri uri = Uri.parse("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=1");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
else if (arg0.getId()==R.id.imageButton1){
((TextView) findViewById(R.id.textView3)).setText("Pressed: " + ++howManyClicks2);
Uri uri = Uri.parse("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=2");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
else if (arg0.getId()==R.id.imageButton2){
((TextView) findViewById(R.id.textView5)).setText("Pressed: " + ++howManyClicks3);
Uri uri = Uri.parse("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=3");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
else if (arg0.getId()==R.id.imageButton4){
((TextView) findViewById(R.id.textView6)).setText("Pressed: " + ++howManyClicks4);
Uri uri = Uri.parse("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=4");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
我希望用户在不打开新窗口的情况下按下图像按钮和URL,-澄清:我不想向用户显示当他/她按下URL链接时会发生什么的网页,只是它已被按下。
萧十郎
偶然的你
哆啦的时光机
相关分类