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

Android App Navigation and Layout Code

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)
5 views13 pages

Android App Navigation and Layout Code

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

CODE SOURCE PASSAGE D’UNE FENETRE VERS UNE AUTRES

public void nom_du_onclick(View view)


{
Intent nom_intent = new Intent(this,[Link]);
startActivity(nom_intent);
}

SPLASH SCREEN

public class MainActivity extends AppCompatActivity {


Timer timer;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
timer = new Timer();
[Link](new TimerTask() {
@Override
public void run() {
Intent intent = new Intent([Link],[Link]);
startActivity(intent);
finish();
}
},3000);
}
}

LAYOUT AVEC PLUSIEURS BLOC

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


<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
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>
</[Link]>

VIDEO
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
[Link](savedInstanceState);
setContentView([Link].activity_main);

VideoView videoView = findViewById([Link]);


String videoPath = "[Link]://" + getPackageName() + "/" + [Link];
Uri uri = [Link](videoPath);
[Link](uri);

MediaController mediaController = new MediaController(this);


[Link](mediaController);
[Link](videoView);
}
}
DOSSIER RAW DANS RES
FORMAT XML
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
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>
</[Link]>

LIEN

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

<[Link]
xmlns:android="[Link]

xmlns:app="[Link]

xmlns:tools="[Link]

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>

</[Link]>

LISTE D’ELEMENTS
JAVA
public class MainActivity4 extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main4);
getSupportActionBar().hide();//cacher la barre des titres

ListView listView = findViewById([Link]);


List<String> list = new ArrayList<>();
[Link]("bloc 1");
[Link]("bloc 2");
[Link]("bloc 3");
[Link]("bloc 4");
[Link]("bloc 5");

ArrayAdapter arrayAdapter = new ArrayAdapter(getApplicationContext(),


[Link].simple_list_item_1,list);
[Link](arrayAdapter);

[Link](new [Link]() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if(i == 0)
{
startActivity(new Intent([Link],[Link]));
}
else if(i == 1)
{
startActivity(new Intent([Link],[Link]));
}
else
{

}
}
});
}
}

XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
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="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
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) {
[Link](savedInstanceState);
setContentView([Link].activity_main4);
getSupportActionBar().hide();//cacher la barre des titres

ListView listView = findViewById([Link]);


List<String> list = new ArrayList<>();
[Link]("bloc 1");
[Link]("bloc 2");
[Link]("bloc 3");
[Link]("bloc 4");
[Link]("bloc 5");

ArrayAdapter arrayAdapter = new ArrayAdapter(getApplicationContext(),


[Link].simple_list_item_1,list);
[Link](arrayAdapter);
[Link](new [Link]() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if(i == 0)
{
startActivity(new Intent([Link],[Link]));
}
else if(i == 1)
{
startActivity(new Intent([Link],[Link]));
}
else
{

}
}
});
}
}

You might also like