Issue
I have button at the top of sreeen and camera preview at beneath, when I press button screen is blinking, but want it to show Toast. It stopped to blink after I commented out Toast.makeText(), and log shows that button was clicked.
Component tree (just in case, I don't want to change it):
The code:
public final class CaptureActivity extends AppCompatActivity {
Button button;
Context context;
...
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.capture);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(context, "BUTTON clicked", Toast.LENGTH_LONG).show();
Log.d("BUTTON","CLICKED");
}
});
mPreview = (CameraSourcePreview) findViewById(R.id.preview);
mGraphicOverlay = (GraphicOverlay<Graphic>) findViewById(R.id.graphicOverlay);
Solution
Where have you defined Context
?
It's null
. It may be ok if you put getApplicationContext()
Answered By - Md.ibrahim khalil
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.