0% found this document useful (0 votes)
23 views13 pages

Code Source Android Studio

Uploaded by

dimzobass
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views13 pages

Code Source Android Studio

Uploaded by

dimzobass
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CODE SOURCE PASSAGE D’UNE FENETRE VERS UNE AUTRES

public void nom_du_onclick(View view)


{
Intent nom_intent = new Intent(this,MainActivity2.class);
startActivity(nom_intent);
}

SPLASH SCREEN

public class MainActivity extends AppCompatActivity {


Timer timer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this,MainActivity2.class);
startActivity(intent);
finish();
}
},3000);
}
}

LAYOUT AVEC PLUSIEURS BLOC

<?xml version="1.0" encoding="utf-8"?>


<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity2">

<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10sp"
android:rowCount="5"
android:columnCount="2">

<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/android2"/>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/android3"/>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/android2"/>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/android3"/>
</GridLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

VIDEO
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

VideoView videoView = findViewById(R.id.video);


String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.video;
Uri uri = Uri.parse(videoPath);
videoView.setVideoURI(uri);

MediaController mediaController = new MediaController(this);


videoView.setMediaController(mediaController);
mediaController.setAnchorView(videoView);
}
}
DOSSIER RAW DANS RES
FORMAT XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<VideoView
android:id="@+id/video"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

LIEN

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity2">

<GridLayout

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="10sp"
android:columnCount="2"

android:rowCount="5"

tools:layout_editor_absoluteX="13dp"

tools:layout_editor_absoluteY="80dp">

<Button

android:id="@+id/button1"

android:layout_rowWeight="1"

android:layout_columnWeight="1"

android:layout_gravity="fill"

android:layout_margin="5sp"

android:onClick="taxi"

android:text="Taxi"

android:textSize="20sp"

android:textStyle="bold"

app:backgroundTint="@color/teal_700"

app:cornerRadius="30dp"

app:iconGravity="end" />

<Button

android:id="@+id/button2"

android:layout_rowWeight="1"
android:layout_columnWeight="1"

android:layout_gravity="fill"

android:layout_margin="5sp"

android:backgroundTint="?attr/colorSecondaryVariant"

android:fontFamily="monospace"

android:onClick="rest"

android:text="Restaurants"

android:textSize="18sp"

android:textStyle="bold"

app:cornerRadius="30dp" />

<Button

android:id="@+id/button3"

android:layout_rowWeight="1"

android:layout_columnWeight="1"

android:layout_gravity="fill"

android:layout_margin="5sp"

android:backgroundTint="@color/purple_500"

android:onClick="covoi"

android:text="covoiturage"

android:textSize="18sp"

android:textStyle="bold"
app:cornerRadius="30dp" />

<Button

android:id="@+id/button4"

android:layout_rowWeight="1"

android:layout_columnWeight="1"

android:layout_gravity="fill"

android:layout_margin="5sp"

android:backgroundTint="@color/purple_200"

android:onClick="depanne"

android:text="Depannage"

android:textSize="18sp"

android:textStyle="bold"

app:cornerRadius="30dp" />

<Button

android:id="@+id/button5"

android:layout_rowWeight="1"

android:layout_columnWeight="1"

android:layout_gravity="fill"

android:layout_margin="5sp"

android:backgroundTint="@color/material_on_background_emphasis_medium"
android:onClick="page5"

android:text="Hebergement"

android:textSize="18sp"

android:textStyle="bold"

app:cornerRadius="30dp" />

<Button

android:id="@+id/button6"

android:layout_rowWeight="1"

android:layout_columnWeight="1"

android:layout_gravity="fill"

android:layout_margin="5sp"

android:onClick="page6"

android:text="SERVICES"

android:textSize="18sp"

android:textStyle="bold"

app:cornerRadius="30dp" />

<Button

android:id="@+id/button7"

android:layout_rowWeight="1"

android:layout_columnWeight="1"
android:layout_gravity="fill"

android:layout_margin="5sp"

android:backgroundTint="@android:color/holo_orange_light"

android:onClick="page7"

android:text="Evenements"

android:textSize="18sp"

android:textStyle="bold"

app:cornerRadius="30dp" />

<Button

android:id="@+id/button8"

android:layout_rowWeight="1"

android:layout_columnWeight="1"

android:layout_gravity="fill"

android:layout_margin="5sp"

android:backgroundTint="@color/black"

android:onClick="page8"

android:text="Livraisons"

android:textSize="18sp"

android:textStyle="bold"

app:cornerRadius="30dp" />
</GridLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

LISTE D’ELEMENTS
JAVA
public class MainActivity4 extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main4);
getSupportActionBar().hide();//cacher la barre des titres

ListView listView = findViewById(R.id.listview);


List<String> list = new ArrayList<>();
list.add("bloc 1");
list.add("bloc 2");
list.add("bloc 3");
list.add("bloc 4");
list.add("bloc 5");

ArrayAdapter arrayAdapter = new ArrayAdapter(getApplicationContext(),


android.R.layout.simple_list_item_1,list);
listView.setAdapter(arrayAdapter);

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if(i == 0)
{
startActivity(new Intent(MainActivity4.this,MainActivity5.class));
}
else if(i == 1)
{
startActivity(new Intent(MainActivity4.this,MainActivity6.class));
}
else
{

}
}
});
}
}

XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity4">

<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</RelativeLayout>

Liste
xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity4">

<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</RelativeLayout>
Java
public class MainActivity4 extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main4);
getSupportActionBar().hide();//cacher la barre des titres

ListView listView = findViewById(R.id.listview);


List<String> list = new ArrayList<>();
list.add("bloc 1");
list.add("bloc 2");
list.add("bloc 3");
list.add("bloc 4");
list.add("bloc 5");

ArrayAdapter arrayAdapter = new ArrayAdapter(getApplicationContext(),


android.R.layout.simple_list_item_1,list);
listView.setAdapter(arrayAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if(i == 0)
{
startActivity(new Intent(MainActivity4.this,MainActivity5.class));
}
else if(i == 1)
{
startActivity(new Intent(MainActivity4.this,MainActivity6.class));
}
else
{

}
}
});
}
}

You might also like