Page horizontal

Debut de fragment
Duex bouton qui s'affiche enfin
navigation
Pierre BALLANDRAS 2 years ago
parent 08c54d58ab
commit d192c45739

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidTestResultsUserPreferences">
<option name="androidTestResultsTableState">
<map>
<entry key="28629151">
<value>
<AndroidTestResultsTableState>
<option name="preferredColumnWidths">
<map>
<entry key="Duration" value="90" />
<entry key="Nexus_6_API_33" value="120" />
<entry key="Tests" value="360" />
</map>
</option>
</AndroidTestResultsTableState>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -37,6 +37,9 @@ dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.fragment:fragment-ktx:1.5.5'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

@ -1,28 +1,29 @@
package iut.android.pierrepierre
import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle
import android.os.PersistableBundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import iut.android.pierrepierre.fragment.FragmentMaster
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
super.onCreate(savedInstanceState, persistentState)
throw Exception("La")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)
val game = findViewById<Button>(R.id.button)
val game = findViewById<Button>(R.id.button_jouer)
game.setOnClickListener{
findViewById<TextView>(R.id.textView).text = "C'est bon"
findViewById<TextView>(R.id.textView).text = getString(R.string.test2)
}
supportFragmentManager.beginTransaction()
.setReorderingAllowed(true)
.add(R.id.linear_main_vertical, FragmentMaster())
.commit()
}
// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
// val imageBitmap = data.extras.get("data") as Bitmap

@ -0,0 +1,13 @@
package iut.android.pierrepierre.fragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentFactory
class FabriqueFragment : FragmentFactory() {
override fun instantiate(classLoader: ClassLoader, className: String): Fragment {
return when (className) {
FragmentMaster::class.java.name -> FragmentMaster()
else -> super.instantiate(classLoader, className)
}
}
}

@ -0,0 +1,11 @@
package iut.android.pierrepierre.fragment
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
class FragmentMaster : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}

@ -1,35 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<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">
<LinearLayout
android:layout_width="409dp"
android:layout_height="729dp"
android:id="@+id/linear_main_vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
>
<Button
android:id="@+id/button"
android:id="@+id/button_jouer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttonGame" />
<Button
android:id="@+id/button2"
android:id="@+id/button_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttonScore" />
<TextView
android:id="@+id/textView"
android:background="@color/teal_200"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test" />
android:text="@string/test1" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,33 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<Button
android:id="@+id/button_jouer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttonGame" />
<Button
android:id="@+id/button_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttonScore" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -2,5 +2,6 @@
<string name="app_name">Pierre&amp;Pierre</string>
<string name="buttonGame">Jouer</string>
<string name="buttonScore">Score</string>
<string name="test">Test</string>
<string name="test1">Test 1</string>
<string name="test2">Test 2</string>
</resources>
Loading…
Cancel
Save