Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.Intent;
- import android.content.SharedPreferences;
- import android.os.Bundle;
- import android.support.annotation.NonNull;
- import android.support.design.widget.BottomNavigationView;
- import android.support.v7.app.AppCompatActivity;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.EditText;
- import android.widget.TextView;
- public class MainActivity extends AppCompatActivity {
- private TextView mTextMessage;
- private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
- = new BottomNavigationView.OnNavigationItemSelectedListener() {
- @Override
- public boolean onNavigationItemSelected(@NonNull MenuItem item) {
- switch (item.getItemId()) {
- case R.id.navigation_home:
- mTextMessage.setText(R.string.title_home);
- return true;
- case R.id.navigation_dashboard:
- mTextMessage.setText(R.string.title_dashboard);
- return true;
- case R.id.navigation_notifications:
- mTextMessage.setText(R.string.title_notifications);
- return true;
- }
- return false;
- }
- };
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mTextMessage = (TextView) findViewById(R.id.message);
- BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
- navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
- }
- public void loginProcess(View view) {
- EditText userName = (EditText) findViewById(R.id.userName);
- EditText password = (EditText) findViewById(R.id.password);
- String username = userName.getText().toString();
- SharedPreferences sharedPreferences = getSharedPreferences("username", MODE_PRIVATE);
- sharedPreferences.edit().putString("message", username).apply();
- Intent intent = new Intent(getApplicationContext(), Main2Activity.class);
- startActivity(intent);
- finish();
- }
- }
Add Comment
Please, Sign In to add comment