New to android here. Looked through the other answers, but still couldn't figure out what was wrong... hoping for some help here. :)
Android Studio says there is a null object reference at line 28 which is the login.setOnClick... line.
Again, sorry if this code is a mess, I am kinda winging it!
Thanks in advance!
public class LoginScreen extends ActionBarActivity {
// EditText mEdit;
// TextView mText;
private static String artist = "Artist";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_screen);
Button login = (Button) findViewById(R.id.button1);
final EditText user = (EditText) findViewById(R.id.userName);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// mText = (TextView)findViewById(R.id.welcome);
// mText.setText("Welcome "+mEdit.getText().toString()+"!");
artist = user.getText().toString();
Intent intent = new Intent(getApplicationContext(), SongSelection.class);
startActivity(intent);
}
});
}
public static String getArtist(){
return artist;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_login_screen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}