I need to do setVisibility for an imageview named "heart" through handler and and function get(A). I declared imageview heart as a final variable in the onCreation method and under the class named Another Activity. But whenever I tried to set visibility for "heart", my application stopped with the log saying: (For more information, handler and other things worked correctly. This is for actually timer function. But I need to comingle timer function with the image visibility and tried to put setvisibility in this statement)
07-31 01:29:49.740: E/AndroidRuntime(2689): at org.voca.AnotherActivity.getEllapse(AnotherActivity.java:1559) 07-31 01:29:49.740: E/AndroidRuntime(2689): at org.voca.AnotherActivity.access$0(AnotherActivity.java:1531) 07-31 01:29:49.740: E/AndroidRuntime(2689): at org.voca.AnotherActivity$1.handleMessage(AnotherActivity.java:1519) 07-31 01:29:49.740: E/AndroidRuntime(2689): at android.os.Handler.dispatchMessage(Handler.java:102) 07-31 01:29:49.740: E/AndroidRuntime(2689): at android.os.Looper.loop(Looper.java:137) 07-31 01:29:49.740: E/AndroidRuntime(2689): at android.app.ActivityThread.main(ActivityThread.java:4998) 07-31 01:29:49.740: E/AndroidRuntime(2689): at java.lang.reflect.Method.invokeNative(Native Method) 07-31 01:29:49.740: E/AndroidRuntime(2689): at java.lang.reflect.Method.invoke(Method.java:515) 07-31 01:29:49.740: E/AndroidRuntime(2689): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 07-31 01:29:49.740: E/AndroidRuntime(2689): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 07-31 01:29:49.740: E/AndroidRuntime(2689): at dalvik.system.NativeStart.main(Native Method)
Below is the abstract code that I erased unimportant part ( as I think..)
//code starts from here.
public class AnotherActivity extends Activity {
ImageView heart;
public void onCreation(Bundle savedInstanceState) {
...
final ImageView heart = (ImageView) findViewById(R.id.heart);
Start.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
}});
}//onCreation close
Handler mTimer = new Handler() {
public void handleMessage(Message msg) {
OUTPUTA.setText(getA());
}
};
private String getA() {
heart6.setVisibility(ImageView.INVISIBLE);
...
}
}//close AnotherActivity
I'm looking forward to seeing the expert's opinions :)
0 comments:
Post a Comment