質問編集履歴
1
コードの開示
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,4 +5,88 @@
|
|
5
5
|
|
6
6
|
②メイン画面にすべての画面分のレイアウトを記述する
|
7
7
|
|
8
|
-
①・②のどちらですか?
|
8
|
+
①・②のどちらですか?
|
9
|
+
|
10
|
+
メイン画面のJava
|
11
|
+
```ここに言語を入力
|
12
|
+
package com.example.club_.music;
|
13
|
+
|
14
|
+
import android.app.Activity;
|
15
|
+
import android.os.Bundle;
|
16
|
+
import android.support.annotation.NonNull;
|
17
|
+
import android.support.design.widget.BottomNavigationView;
|
18
|
+
import android.support.v7.app.AppCompatActivity;
|
19
|
+
import android.view.MenuItem;
|
20
|
+
import android.widget.TextView;
|
21
|
+
|
22
|
+
//public class Main extends AppCompatActivity {
|
23
|
+
public class Main extends Activity{
|
24
|
+
private TextView mTextMessage;
|
25
|
+
|
26
|
+
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
27
|
+
= new BottomNavigationView.OnNavigationItemSelectedListener() {
|
28
|
+
|
29
|
+
@Override
|
30
|
+
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
31
|
+
switch (item.getItemId()) {
|
32
|
+
case R.id.item_music:
|
33
|
+
mTextMessage.setText(R.string.Music);
|
34
|
+
return true;
|
35
|
+
case R.id.item_folder:
|
36
|
+
mTextMessage.setText(R.string.Folder);
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
|
42
|
+
};
|
43
|
+
|
44
|
+
@Override
|
45
|
+
protected void onCreate(Bundle savedInstanceState) {
|
46
|
+
super.onCreate(savedInstanceState);
|
47
|
+
setContentView(R.layout.main);
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
52
|
+
```
|
53
|
+
メイン画面のxml
|
54
|
+
```ここに言語を入力
|
55
|
+
<?xml version="1.0" encoding="utf-8"?>
|
56
|
+
<LinearLayout
|
57
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
58
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
59
|
+
xmlns:tools="http://schemas.android.com/tools"
|
60
|
+
android:id="@+id/container"
|
61
|
+
android:layout_width="match_parent"
|
62
|
+
android:layout_height="match_parent"
|
63
|
+
android:orientation="vertical"
|
64
|
+
tools:context="com.example.club_.music.Main">
|
65
|
+
|
66
|
+
<FrameLayout
|
67
|
+
android:id="@+id/content"
|
68
|
+
android:layout_width="match_parent"
|
69
|
+
android:layout_height="0dp"
|
70
|
+
android:layout_weight="1">
|
71
|
+
|
72
|
+
<TextView
|
73
|
+
android:id="@+id/message"
|
74
|
+
android:layout_width="match_parent"
|
75
|
+
android:layout_height="wrap_content"
|
76
|
+
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
77
|
+
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
78
|
+
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
79
|
+
android:layout_marginTop="@dimen/activity_vertical_margin"
|
80
|
+
android:text="@string/Music"/>
|
81
|
+
|
82
|
+
</FrameLayout>
|
83
|
+
|
84
|
+
<android.support.design.widget.BottomNavigationView
|
85
|
+
android:id="@+id/navigation"
|
86
|
+
android:layout_width="match_parent"
|
87
|
+
android:layout_height="wrap_content"
|
88
|
+
android:layout_gravity="bottom"
|
89
|
+
android:background="?android:attr/windowBackground"
|
90
|
+
app:menu="@menu/navigation"/>
|
91
|
+
</LinearLayout>
|
92
|
+
```
|