Hi
The following crashes and burns when the button is pressed, I suspect Line 34/35 to be at fault.
Can someone take note of line 36 and explain context for me?
[HIGH]package com.example.tostertime;
import java.util.Calendar;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
Button ToTime;
Button button1;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ToTime =(Button) this.findViewById(R.id.button1);
ToTime.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
ToTime.setText("onRun");
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
Context context = null;
Toast.makeText(context,"Time "+mydate,5);
//Can someone explain ^^ Context what's acceptable
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
[/HIGH]
Hope these posts are ok here their not being moved so I guess so.
The following crashes and burns when the button is pressed, I suspect Line 34/35 to be at fault.
Can someone take note of line 36 and explain context for me?
[HIGH]package com.example.tostertime;
import java.util.Calendar;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
Button ToTime;
Button button1;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ToTime =(Button) this.findViewById(R.id.button1);
ToTime.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
ToTime.setText("onRun");
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
Context context = null;
Toast.makeText(context,"Time "+mydate,5);
//Can someone explain ^^ Context what's acceptable
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
[/HIGH]
Hope these posts are ok here their not being moved so I guess so.