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:
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..)
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