1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
| package com.vahia.monappli;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends FragmentActivity {
private int height = 1;
private Button1 = null;
private Button2 = null;
private Button3 = null;
public Fragment layoutcontenuapd5;
public Fragment Frag;
public Fragment firstFragGen;
private static String frag3Tag;
private static String frag4Tag;
private static String frag1Tag;
private static String frag2Tag;
private String mFragment;
private final Frag1 mFrag1 = new Frag1();
private final Frag2 mFrag2 = new ();
public Frag3 mFrag3 = new Frag3();
private final Frag4 mFrag4 = new Frag4();
private final PassesD5 mPassesD5 = new PassesD5();
public TextView textView1 = null;
public TextView textView2 = null;
public TextView textView3 = null;
public TextView textView4 = null;
public TextView textView5 = null;
public TextView textView6 = null;
public TextView textView7 = null;
public TextView textView8 = null;
public TextView textView9 = null;
public TextView textView10 = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
height = metrics.heightPixels;
if (height == 1080)
setContentView(R.layout.activity_main_activity_d51080);
else
setContentView(R.layout.activity_main_activity_d5);
firstFrag();
bouton1 = (Button) findViewById(R.id.bouton1);
bouton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View mainView) {
goToFrag3(mainView);
//mFrag3.passes();
bouton1();
}});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_activity, 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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
private void showFrag (final Fragment fragment) {
if (fragment == null)
return;
mFragment = ((Object) fragment).getClass().getSimpleName();
final FragmentManager fm = getSupportFragmentManager();
final FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.frag, fragment, frag3Tag);
ft.commit();
}
private void firstFrag () {
firstFragGen = new Frag0();
final FragmentManager fm1 = getSupportFragmentManager();
final FragmentTransaction ft1 = fm1.beginTransaction();
ft1.add(R.id.frag, firstFragGen);
ft1.commit();
}
public void goToFrag1(View mainView) {
showFrag(this.mFrag1);
}
public void goToFrag2(View mainView) {
showFrag(this.mFrag2);
}
public void goToFrag3(View mainView) {
showFrag(this.mFrag3);
}
public void goToFrag4(View mainView) {
showFrag(this.mFrag4);
}
public void bouton1(){
textView1 = (TextView) findViewById(R.id.textview1);
textView2 = (TextView) findViewById(R.id.textview2);
textView3 = (TextView) findViewById(R.id.textview3);
textView4 = (TextView) findViewById(R.id.textview4);
textView5 = (TextView) findViewById(R.id.textview5);
textView6 = (TextView) findViewById(R.id.textview6);
textView7 = (TextView) findViewById(R.id.textview7);
textView8 = (TextView) findViewById(R.id.textview8);
textView9 = (TextView) findViewById(R.id.textview9);
textView10 = (TextView) findViewById(R.id.textview10);
textView1.setText("texte1");
textView2.setText("texte2");
textView3.setText("texte3");
textView4.setText("texte4");
textView5.setText("texte5");
textView6.setText("texte6");
textView7.setText("texte7");
textView8.setText("texte8");
textView9.setText("texte9");
textView10.setText("texte10");
}
} |