Java 使用WebView onTouchListener-Android链接到另一个活动
我在这个主页上设置了多个Web视图。基本上,这个想法很简单。我使用三种网络视图,它们都从一个在线网站获取不同的内容。当他们点击web视图时,它会将他们带到另一个活动。那剩下的就交给我吧。我只需要帮助使用onTouchListener将web视图链接到另一个活动 这是我的Java文件:查找Java 使用WebView onTouchListener-Android链接到另一个活动,java,android,android-intent,webview,ontouchlistener,Java,Android,Android Intent,Webview,Ontouchlistener,我在这个主页上设置了多个Web视图。基本上,这个想法很简单。我使用三种网络视图,它们都从一个在线网站获取不同的内容。当他们点击web视图时,它会将他们带到另一个活动。那剩下的就交给我吧。我只需要帮助使用onTouchListener将web视图链接到另一个活动 这是我的Java文件:查找//OnTucheveton的代码从这里开始行。这就是我尝试webview 1启动第二个活动的地方。我试图使用以下内容:Intent myIntentActivity1=newintent(这是ReadComme
//OnTucheveton的代码从这里开始代码>行。这就是我尝试webview 1启动第二个活动的地方。我试图使用以下内容:Intent myIntentActivity1=newintent(这是ReadComments.Class)代码>但是java给了我以下错误:
删除与“Intent()”匹配的参数
这是我的XML文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<Button
android:id="@+id/btn_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btn_login"
android:layout_alignBottom="@+id/btn_login"
android:layout_alignRight="@+id/textView1"
android:background="#333333"
android:minHeight="40dp"
android:minWidth="140dp"
android:text="@string/mainpage_register_button"
android:textColor="#999999" />
<Button
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="280dp"
android:background="#333333"
android:minHeight="40dp"
android:minWidth="140dp"
android:text="@string/main_button_login"
android:textColor="#999999" />
<Button
android:id="@+id/btn_contact_us"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btn_login"
android:layout_alignRight="@+id/btn_register"
android:layout_below="@+id/btn_register"
android:background="#333333"
android:minHeight="40dp"
android:layout_marginTop="2dp"
android:text="@string/mainpage_contact_us"
android:textColor="#999999" />
<ImageView
android:id="@+id/centennialmsssite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btn_contact_us"
android:layout_below="@+id/btn_contact_us"
android:layout_marginTop="14dp"
android:contentDescription="@string/mss_button_description"
android:src="@drawable/msswebsitebutton" />
<TextView
android:id="@+id/textView1"
android:layout_width="286dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:gravity="center"
android:text="@string/welcome_mainpage"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff"
android:textStyle="bold" />
<WebView
android:id="@+id/my_webview"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignLeft="@+id/textView1"
android:layout_alignRight="@+id/sitebutton"
android:layout_below="@+id/textView1"
android:layout_marginTop="12dp"
android:maxHeight="40dp"
android:minHeight="40dp" />
<WebView
android:id="@+id/topic_one"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignLeft="@+id/my_webview"
android:layout_alignRight="@+id/my_webview"
android:layout_below="@+id/my_webview"
android:layout_marginTop="5dp"
android:maxHeight="70dp"
android:minHeight="70dp" />
<WebView
android:id="@+id/topic_two"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignLeft="@+id/topic_one"
android:layout_alignRight="@+id/topic_one"
android:layout_below="@+id/topic_one"
android:maxHeight="70dp"
android:minHeight="70dp" />
<WebView
android:id="@+id/topic_three"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignLeft="@+id/topic_two"
android:layout_alignRight="@+id/topic_two"
android:layout_below="@+id/topic_two"
android:maxHeight="70dp"
android:minHeight="70dp" />
</RelativeLayout>
什么可能导致此错误?请尝试此操作-
Intent myIntentActivity1 = new Intent(mainlogin.this, ReadComments.class);
startActivity(myIntentActivity1);
或-
在这一行中,你正在使用。类,但它是。类从小c字母开始。java是区分大小写的。我的。上帝非常感谢:)我完全忘记了getBaseContext()。这解决了整个问题!你是最棒的:)
Intent myIntentActivity1 = new Intent(mainlogin.this, ReadComments.class);
startActivity(myIntentActivity1);
Intent myIntentActivity1 = new Intent(getBaseContext(), ReadComments.class);
startActivity(myIntentActivity1);