0

嗨,当我单击可从右向左移动的 textview 时,我遇到了 marquee textview 的问题。我想当我点击选框文本时会出现新的活动

当我点击它时,应用程序会崩溃

<TextView
    android:text="||EVENT||"
    android:id="@+id/MarqueeText" 
    android:background="#ff010068" 
    android:textColor="#ffffffff" 
    android:layout_width="fill_parent"
    android:layout_height="22.0sp"
    android:singleLine="true"
    android:ellipsize="marquee" 
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true" 
    android:paddingLeft="15dip" 
    android:paddingRight="15dip" 
    android:focusable="true" 
    android:clickable="true"
    android:focusableInTouchMode="false" 
    android:freezesText="true"
    android:onClick="menuevent"
    />

这是来自 mainactivity 的代码

public void menuevent(View v) {
   Intent inn=new Intent();
   inn.setClass(this,Fourth.class);
   startActivity(inn);
}

这个日志猫

10-09 18:42:14.989: E/AndroidRuntime(3513): FATAL EXCEPTION: main
10-09 18:42:14.989: E/AndroidRuntime(3513): java.lang.IllegalStateException: Could not find a method menueventonClick(View) in the activity class com.test.MainActivity for onClick handler on view class android.widget.TextView with id 'MarqueeText'
10-09 18:42:14.989: E/AndroidRuntime(3513):     at android.view.View$1.onClick(View.java:3044)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at android.view.View.performClick(View.java:3528)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at android.view.View$PerformClick.run(View.java:14235)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at android.os.Handler.handleCallback(Handler.java:605)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at android.os.Looper.loop(Looper.java:137)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at java.lang.reflect.Method.invokeNative(Native Method)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at java.lang.reflect.Method.invoke(Method.java:511)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at dalvik.system.NativeStart.main(Native Method)
10-09 18:42:14.989: E/AndroidRuntime(3513): Caused by: java.lang.NoSuchMethodException: menueventonClick [class android.view.View]
10-09 18:42:14.989: E/AndroidRuntime(3513):     at java.lang.Class.getConstructorOrMethod(Class.java:460)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at java.lang.Class.getMethod(Class.java:915)
10-09 18:42:14.989: E/AndroidRuntime(3513):     at android.view.View$1.onClick(View.java:3037)
10-09 18:42:14.989: E/AndroidRuntime(3513):     ... 11 more
4

1 回答 1

0

用这个

view.getContext().startActivity(
    new Intent(view.getContext().getApplicationContext(), Fourth.class)
);
于 2013-10-09T12:06:42.143 回答