Temukan Berita Teknologi Baru, berita terbaru tentang informasi terkini dalam teknologi, TI, Teknologi Komputer, industri ponsel, berita TI terbaru online, tutorial, atupun pemecahan masalah tentang koding.
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class LoginActivity extends AppCompatActivity{
public static final String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
public static final String EXTRA_MESSAGE2 = "com.example.myfirstapp.MESSAGE2";
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
public void ButtonLogin(View view){
Toast.makeText(this, "Login Bro!", Toast.LENGTH_SHORT).show();
EditText editText = (EditText) findViewById(R.id.username);
String message = editText.getText().toString();
EditText editText2 = (EditText) findViewById(R.id.password);
String message2 = editText2.getText().toString();
if(message.equals("saya")&&message2.equals("test")){
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(EXTRA_MESSAGE, message);
intent.putExtra(EXTRA_MESSAGE2, message2);
startActivity(intent);
}
}
}
activity Main :
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get the Intent that started this activity and extract the stringIntent intent = getIntent();
String message = intent.getStringExtra(LoginActivity.EXTRA_MESSAGE);
// Capture the layout's TextView and set the string as its textTextView textView = findViewById(R.id.title_main);
textView.setText("WELCOME "+message);
}
}
untuk penerapan bisa lihat vidio dibawah:
0 Response to "Code Login Sederhana (Android Studio)"
0 Response to "Code Login Sederhana (Android Studio)"
Posting Komentar