これは私のログイン ビューhttp://i.imgur.com/IfLIHFQ.jpgです。ログインに成功すると、このページhttp://i.imgur.com/4yv3KDv.jpg にリダイレクトされます が、新しいインテントを起動する代わりに、タブ内でアクティビティを進めたい。http://i.imgur.com/sH8HQC7.jpg (注: 最後の写真は、私 が望んでいるもののサンプルを提供するために編集されたフォトショップです)。初心者の質問で申し訳ありませんが、以前はご協力いただきありがとうございました。
これは私のコードです:Tab1.java
public class Tab1 extends Activity {
String var_usr,var_pass;
EditText usr, psw;
JSONArray str_login = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.panel_login);
usr = (EditText) findViewById(R.id.txt_username);
psw = (EditText) findViewById(R.id.txt_pass);
Button submit = (Button) findViewById(R.id.btn_login);
submit.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
var_usr = usr.getText().toString();
var_pass = psw.getText().toString();
String stts = "";
String kode = "";
String link_url = "http://10.0.2.2/gollege/login.php?usr="+var_usr+"&psw="+var_pass;
com.bucheuw.gollege.portal.JSONParser jParser = new com.bucheuw.gollege.portal.JSONParser();
JSONObject json = jParser.AmbilJson(link_url);
try {
str_login = json.getJSONArray("statuslogin");
for(int i = 0; i < str_login.length(); i++){
JSONObject ar = str_login.getJSONObject(i);
TextView st = (TextView) findViewById(R.id.txt_alert);
String alrt = ar.getString("hasil");
stts = ar.getString("st");
kode = ar.getString("id");
st.setText(alrt);
usr.setText("");
psw.setText("");
if(stts.trim().equals("ok"))
{
Intent ni = null;
ni = new Intent(Tab1.this, com.bucheuw.gollege.portal.DashboardActivity.class);
Bundle b = new Bundle();
b.putString("par_kode", kode);
ni.putExtras(b);
startActivity(ni);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
DashboardActivity.java
public class DashboardActivity extends Activity {
public String nim;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.panel_dashboard);
Bundle b = getIntent().getExtras();
nim = b.getString("par_kode");
Button btn_datapribadi = (Button) findViewById(R.id.btn_datapribadi);
Button btn_ksm = (Button) findViewById(R.id.btn_ksm);
Button btn_jdwlkuliah = (Button) findViewById(R.id.btn_jdwlkuliah);
Button btn_absensi = (Button) findViewById(R.id.btn_absensi);
Button btn_nilai = (Button) findViewById(R.id.btn_nilai);
Button btn_tak = (Button) findViewById(R.id.btn_tak);
Button btn_ips = (Button) findViewById(R.id.btn_ips);
Button btn_jdwlujian = (Button) findViewById(R.id.btn_jdwlujian);
Button btn_pengumuman = (Button) findViewById(R.id.btn_pengumuman);
Button btn_klndr = (Button) findViewById(R.id.btn_klndr);
Button btn_logout = (Button) findViewById(R.id.btn_logout);
btn_datapribadi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), DataPribadiActivity.class);
startActivity(i);
}
});
btn_ksm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), KSMActivity.class);
startActivity(i);
}
});
btn_jdwlkuliah.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), JadwalKuliahActivity.class);
startActivity(i);
}
});
btn_absensi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), AbsensiActivity.class);
startActivity(i);
}
});
btn_nilai.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), NilaiActivity.class);
startActivity(i);
}
});
btn_tak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), TAKActivity.class);
startActivity(i);
}
});
btn_ips.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), IPSActivity.class);
startActivity(i);
}
});
btn_jdwlujian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), JadwalUjianActivity.class);
startActivity(i);
}
});
btn_pengumuman.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), InfoKampusActivity.class);
startActivity(i);
}
});
btn_klndr.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), KalenderAkademikActivity.class);
startActivity(i);
}
});
btn_logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent exit = new Intent(Intent.ACTION_MAIN);
exit.addCategory(Intent.CATEGORY_HOME); exit.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
DashboardActivity.this.finish();
}
});
}