eclipseを使って仮想デバイスにですが、電卓アプリを作ろうとしています。
srcのjavaとres/layoutとres/values/strings.xmlの3つを使って作っています。
自信がありませんが、layoutとstringsの部分だけ形としてできたつもりです。
そのlayoutから電卓のようにしたいのですが、javaの部分がわかりません。
よろしければ、javaの部分を教えてください。
一応layoutとstringsの部分を記載します。
何も表示してないボタンはイベントハンドラです。
layout
lang
1LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 7 <TextView 8 android:id="@+id/display" 9 android:layout_width="fill_parent" 10 android:layout_height="wrap_content" 11 android:text="" 12 android:textSize="40dip" 13 android:textColor="#f39800" 14 android:gravity="right" 15 android:background="#999999"/> 16 17<LinearLayout 18 android:layout_width="wrap_content" 19 android:layout_height="wrap_content" 20 android:orientation="horizontal"> 21 22 <Button 23 android:id="@+id/bt_click" 24 android:layout_width="175dp" 25 android:layout_height="wrap_content" 26 android:text="@string/bt_click" /> 27 28 <Button 29 android:id="@+id/bt_AC" 30 android:layout_width="wrap_content" 31 android:layout_height="wrap_content" 32 android:text="@string/bt_AC"/> 33 <Button 34 android:id="@+id/bt_waru" 35 android:layout_width="wrap_content" 36 android:layout_height="wrap_content" 37 android:text="@string/bt_waru"/> 38</LinearLayout> 39 40<LinearLayout 41 android:layout_width="wrap_content" 42 android:layout_height="wrap_content" 43 android:orientation="horizontal" > 44 45 <Button 46 android:id="@+id/bt_7" 47 android:layout_width="wrap_content" 48 android:layout_height="wrap_content" 49 android:text="@string/bt_7" /> 50 51 <Button 52 android:id="@+id/bt_8" 53 android:layout_width="wrap_content" 54 android:layout_height="wrap_content" 55 android:text="@string/bt_8"/> 56 <Button 57 android:id="@+id/bt_9" 58 android:layout_width="wrap_content" 59 android:layout_height="wrap_content" 60 android:text="@string/bt_9"/> 61 <Button 62 android:id="@+id/bt_kake" 63 android:layout_width="wrap_content" 64 android:layout_height="wrap_content" 65 android:text="@string/bt_kake"/> 66</LinearLayout> 67 68<LinearLayout 69 android:layout_width="wrap_content" 70 android:layout_height="wrap_content" 71 android:orientation="horizontal" > 72 73 <Button 74 android:id="@+id/bt_4" 75 android:layout_width="wrap_content" 76 android:layout_height="wrap_content" 77 android:text="@string/bt_4" /> 78 79 <Button 80 android:id="@+id/bt_5" 81 android:layout_width="wrap_content" 82 android:layout_height="wrap_content" 83 android:text="@string/bt_5"/> 84 <Button 85 android:id="@+id/bt_6" 86 android:layout_width="wrap_content" 87 android:layout_height="wrap_content" 88 android:text="@string/bt_6"/> 89 <Button 90 android:id="@+id/bt_hiki" 91 android:layout_width="wrap_content" 92 android:layout_height="wrap_content" 93 android:text="@string/bt_hiki"/> 94</LinearLayout> 95 96<LinearLayout 97 android:layout_width="wrap_content" 98 android:layout_height="wrap_content" 99 android:orientation="horizontal" > 100 101 <Button 102 android:id="@+id/bt_1" 103 android:layout_width="wrap_content" 104 android:layout_height="wrap_content" 105 android:text="@string/bt_1" /> 106 107 <Button 108 android:id="@+id/bt_2" 109 android:layout_width="wrap_content" 110 android:layout_height="wrap_content" 111 android:text="@string/bt_2"/> 112 <Button 113 android:id="@+id/bt_3" 114 android:layout_width="wrap_content" 115 android:layout_height="wrap_content" 116 android:text="@string/bt_3"/> 117 <Button 118 android:id="@+id/bt_tasu" 119 android:layout_width="wrap_content" 120 android:layout_height="wrap_content" 121 android:text="@string/bt_tasu"/> 122</LinearLayout> 123 124<LinearLayout 125 android:layout_width="wrap_content" 126 android:layout_height="wrap_content" 127 android:orientation="horizontal"> 128 129 <Button 130 android:id="@+id/bt_0" 131 android:layout_width="wrap_content" 132 android:layout_height="wrap_content" 133 android:text="@string/bt_0" /> 134 135 <Button 136 android:id="@+id/bt_ten" 137 android:layout_width="wrap_content" 138 android:layout_height="wrap_content" 139 android:text="@string/bt_ten"/> 140 141 <Button 142 android:id="@+id/bt_wa" 143 android:layout_width="140dp" 144 android:layout_height="wrap_content" 145 android:text="@string/bt_wa" /> 146 147</LinearLayout> 148
strings.xml
lang
1<resources> 2 3 <string name="app_name">MyCalculator8</string> 4 <string name="hello_world">Hello world!</string> 5 <string name="action_settings">Settings</string> 6 7 <string name="bt_click"> </string> 8 <string name="bt_AC">AC</string> 9 <string name="bt_waru">÷</string> 10 <string name="bt_7">7</string> 11 <string name="bt_8">8</string> 12 <string name="bt_9">9</string> 13 <string name="bt_kake">×</string> 14 <string name="bt_4">4</string> 15 <string name="bt_5">5</string> 16 <string name="bt_6">6</string> 17 <string name="bt_hiki">-</string> 18 <string name="bt_1">1</string> 19 <string name="bt_2">2</string> 20 <string name="bt_3">3</string> 21 <string name="bt_tasu">+</string> 22 <string name="bt_0">0</string> 23 <string name="bt_ten">.</string> 24 <string name="bt_wa">=</string> 25 26</resources> 27
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/06/16 08:19