0% found this document useful (0 votes)
19 views

1 XML

Uploaded by

yikom vasu
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

1 XML

Uploaded by

yikom vasu
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

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

>
<LinearLayout 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="wrap_content"
tools:context=".MainActivity"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"></TextView>

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

</LinearLayout>

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


<GridLayout 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="wrap_content"
tools:context=".MainActivity"
android:columnCount="4"
android:orientation="horizontal"
>

<TextView
android:id="@+id/textViewOperation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#FF0000"
android:textSize="20sp"
android:layout_columnSpan="3"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
/>
<Button
android:id="@+id/btnDivision"
android:layout_margin="1dp"
android:text="/"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerOperation"
></Button>
<Button
android:id="@+id/btn1"
android:text="1"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btn2"
android:text="2"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btn3"
android:text="3"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btnProduit"
android:text="*"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerOperation"
>
></Button>

<Button
android:id="@+id/btn4"
android:text="4"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btn5"
android:text="5"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btn6"
android:text="6"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btnSoustraction"
android:text="-"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerOperation"
>
></Button>
<Button
android:id="@+id/btn7"
android:text="7"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btn8"
android:text="8"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btn9"
android:text="9"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btnPlus"
android:text="+"
android:layout_margin="1dp"
android:layout_rowSpan="3"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerOperation"
>
></Button>

<Button
android:id="@+id/btn0"
android:text="0"
android:layout_margin="1dp"
android:layout_columnSpan="2"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btnPoint"
android:text="."
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerChiffre"
>
></Button>
<Button
android:id="@+id/btnEgale"
android:text="="
android:layout_margin="1dp"
android:layout_columnSpan="2"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
>
></Button>
<Button
android:id="@+id/btnC"
android:text="c"
android:layout_margin="1dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:onClick="cliquerC"
>
></Button>
</GridLayout>

XML EXAMPLE SANS JAVA


<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"
android:layout_height="match_parent"
android:stretchColumns="0,1,2"
android:layout_gravity="center" >

<TableRow
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="1dp"
android:layout_weight="1"
>
<TableRow
android:background="#000000"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="1dp"
android:layout_weight="1"
>

</TableRow>
</TableRow>
<TableRow
android:background="#000000"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="1dp"
android:layout_weight="1"

>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Date "
android:layout_margin="1dp"
android:layout_column="0"
android:background="#FFFFFF"
android:textStyle="bold"
android:gravity="center"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Miles "
android:layout_margin="1dp"
android:layout_column="1"
android:background="#FFFFFF"
android:gravity="center"
android:textStyle="bold"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Calories"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:textStyle="bold"
android:layout_column="2"
/>
</TableRow>

<TableRow
android:background="#000000"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="1dp"
android:layout_weight="1"
>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:layout_column="0"
android:background="#FFFFFF"
android:gravity="center"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:layout_column="1"
android:background="#FFFFFF"
android:gravity="center"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:layout_column="2" />
</TableRow>

<TableRow
android:background="#000000"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="1dp"
android:layout_weight="1"
>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:layout_column="0"
android:background="#FFFFFF"
android:gravity="center"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:layout_column="1"
android:background="#FFFFFF"
android:gravity="center"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:layout_column="2" />
</TableRow>

<TableRow
android:background="#000000"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="1dp"
android:layout_weight="1"
>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:layout_column="0"
android:background="#FFFFFF"
android:gravity="center"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:layout_column="1"
android:background="#FFFFFF"
android:gravity="center"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=" Text"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:layout_column="2" />
</TableRow>

</TableLayout>

ELEMENT LAYOUT
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"

>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
> </ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"></LinearLayout>
<TextView
android:id="@+id/titre"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="16px"
android:textStyle="bold">

</TextView>
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</TextView>

</LinearLayout>

COLOR WHEEL 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=".MainActivity"
android:textSize="24sp"
android:background="#ff51b46d"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fourmis etendent quand ils se reveillent le matin."
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_alignParentStart="true"
android:textSize="24sp"
android:textColor="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Monter Autre Fait Amusant"
android:id="@+id/showFactButton"
android:layout_alignParentBottom="true"
android:backgroundTint="@color/white"
android:textColor="#ff51b46d">

</Button>

</RelativeLayout>

ACTIVITE 6 1

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


<LinearLayout 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"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/myStyle"
android:text="Hello Word"
>

</TextView>

<!-- etape1-->
<ListView
android:id="@+id/mailListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>

</LinearLayout>

SIMPLE LAYOUT ELEMENT

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


<!--etape2-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:textSize="18sp"
android:background="#AAAAAA"
android:textColor="@color/white"
>

</TextView>

JAVA
package com.example.activite6_1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.io.StringBufferInputStream;

public class MainActivity extends AppCompatActivity {

//etape3 : localiser les données de la liste


String[] planetes=new String[]
{
"Mercury",
"Venus",
"Earth",
"Mars",
"Jupiter"
};

ArrayAdapter<String> adapter;
ListView listeView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Referencer la liste
listeView = findViewById(R.id.mailListView);
//etape 4 : Creer l'adapter
//Pour les listes simples => ArrayAdapter
adapter = new ArrayAdapter<String>
(this,
R.layout.simpllayoutelement,
planetes);

//etape5 : associer le ListView à l'adapter


listeView.setAdapter(adapter);
}
}

You might also like