比率変更

リストビューとダイアログ

前回はこちら。

 今回から、また新たなプロジェクトです、まずはstring.xmlを書き換えていきます。

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

<resources>
    <string name="app_name">リスト選択サンプル</string>
<string-array name="lv_name">
<item>から揚げ定食</item>
<item>ハンバーグ定食</item>
<item>生姜焼き定食</item>
<item>ステーキ定食</item>
<item>野菜炒め定食</item>
<item>とんかつ定食</item>
<item>ミンチカツ定食</item>
<item>コロッケ定食</item>
<item>焼き魚定食</item>
<item>焼き肉定食</item>
</string-array>
</resources>

 続いてactivity_list_view_sample.xmlの書き換えです。

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


<ListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:entries="@array/lv_name"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

 相変わらずデザインモードだと表示内容がおかしいのですが、エミュレータではちゃんと表示されているのでよしとします。次回は、リストをタップしたときの処理を記述していきます。

つづく!

ここから先は

0字

¥ 100

期間限定 PayPay支払いすると抽選でお得に!

この記事が気に入ったらサポートをしてみませんか?