daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest May 27th, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import android.content.Intent;
  2. import android.content.SharedPreferences;
  3. import android.os.Bundle;
  4. import android.support.annotation.NonNull;
  5. import android.support.design.widget.BottomNavigationView;
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.view.MenuItem;
  8. import android.view.View;
  9. import android.widget.EditText;
  10. import android.widget.TextView;
  11.  
  12. public class MainActivity extends AppCompatActivity {
  13.  
  14.     private TextView mTextMessage;
  15.  
  16.     private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
  17.             = new BottomNavigationView.OnNavigationItemSelectedListener() {
  18.  
  19.         @Override
  20.         public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  21.             switch (item.getItemId()) {
  22.                 case R.id.navigation_home:
  23.                     mTextMessage.setText(R.string.title_home);
  24.                     return true;
  25.                 case R.id.navigation_dashboard:
  26.                     mTextMessage.setText(R.string.title_dashboard);
  27.                     return true;
  28.                 case R.id.navigation_notifications:
  29.                     mTextMessage.setText(R.string.title_notifications);
  30.                     return true;
  31.             }
  32.             return false;
  33.         }
  34.     };
  35.  
  36.     @Override
  37.     protected void onCreate(Bundle savedInstanceState) {
  38.         super.onCreate(savedInstanceState);
  39.         setContentView(R.layout.activity_main);
  40.  
  41.         mTextMessage = (TextView) findViewById(R.id.message);
  42.         BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
  43.         navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
  44.     }
  45.  
  46.     public void loginProcess(View view) {
  47.         EditText userName = (EditText) findViewById(R.id.userName);
  48.         EditText password = (EditText) findViewById(R.id.password);
  49.         String username = userName.getText().toString();
  50.         SharedPreferences sharedPreferences = getSharedPreferences("username", MODE_PRIVATE);
  51.         sharedPreferences.edit().putString("message", username).apply();
  52.         Intent intent = new Intent(getApplicationContext(), Main2Activity.class);
  53.         startActivity(intent);
  54.         finish();
  55.     }
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top