OSDN Git Service

add graphic for task. and create layout of task(sample).
authorkato-sh4k <kato.t.an@m.titech.ac.jp>
Mon, 29 Oct 2012 11:30:35 +0000 (20:30 +0900)
committerkato-sh4k <kato.t.an@m.titech.ac.jp>
Mon, 29 Oct 2012 11:30:35 +0000 (20:30 +0900)
Circuit/res/drawable/and.png [new file with mode: 0644]
Circuit/res/drawable/not.png [new file with mode: 0644]
Circuit/res/drawable/or.png [new file with mode: 0644]
Circuit/res/drawable/question.png [new file with mode: 0644]
Circuit/res/layout/main.xml
Circuit/res/values/strings.xml
Circuit/src/jp/ac/titech/sharp4k/cuten/CircuitActivity.java
Circuit/src/jp/ac/titech/sharp4k/cuten/app/CircuitTask.java

diff --git a/Circuit/res/drawable/and.png b/Circuit/res/drawable/and.png
new file mode 100644 (file)
index 0000000..5318e46
Binary files /dev/null and b/Circuit/res/drawable/and.png differ
diff --git a/Circuit/res/drawable/not.png b/Circuit/res/drawable/not.png
new file mode 100644 (file)
index 0000000..fdcb16b
Binary files /dev/null and b/Circuit/res/drawable/not.png differ
diff --git a/Circuit/res/drawable/or.png b/Circuit/res/drawable/or.png
new file mode 100644 (file)
index 0000000..855ad02
Binary files /dev/null and b/Circuit/res/drawable/or.png differ
diff --git a/Circuit/res/drawable/question.png b/Circuit/res/drawable/question.png
new file mode 100644 (file)
index 0000000..8222d5c
Binary files /dev/null and b/Circuit/res/drawable/question.png differ
index bc12cd8..1e46f86 100644 (file)
@@ -9,4 +9,10 @@
         android:layout_height="wrap_content"
         android:text="@string/hello" />
 
+    <Button
+        android:id="@+id/button1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/test_btn" />
+
 </LinearLayout>
\ No newline at end of file
index f3e7790..977e9a1 100644 (file)
@@ -3,5 +3,6 @@
 
     <string name="hello">Hello World, CircuitActivity!</string>
     <string name="app_name">Circuit</string>
+    <string name="test_btn">Toast</string>
 
 </resources>
\ No newline at end of file
index a8ec13a..4565bba 100644 (file)
@@ -29,6 +29,7 @@ public class CircuitActivity extends Activity implements ResultSender,
                layout.setOrientation(LinearLayout.VERTICAL);
                Button b = new Button(this);
                b.setOnClickListener(this);
+               b.setText("Exit");
                layout.addView(b);
                layout.addView(taskApp.createView(this, this.getResources()));
                setContentView(layout);
index ad8c054..8bd1bcc 100644 (file)
@@ -1,27 +1,66 @@
 package jp.ac.titech.sharp4k.cuten.app;
 
+import jp.ac.titech.sharp4k.cuten.BaseApp;
+import jp.ac.titech.sharp4k.cuten.R;
 import android.content.Context;
 import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
 import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
 import android.widget.Button;
+import android.widget.ImageView;
 import android.widget.LinearLayout;
-import jp.ac.titech.sharp4k.cuten.BaseApp;
+import android.widget.Toast;
 
-public class CircuitTask extends BaseApp {
+public class CircuitTask extends BaseApp implements OnClickListener{
+       static final int FP = ViewGroup.LayoutParams.FILL_PARENT;
+       static final int WC = ViewGroup.LayoutParams.WRAP_CONTENT;
+       
        private static final String TAG = CircuitTask.class.getSimpleName();
        private Context cxt;
        private Resources res;
+       private Button submitBtn;
+       private Button[] selectBtnAllay;
+
 
        @Override
-       protected View createView(Context cxt, Resources res) {
+       protected View createView(final Context cxt, Resources res) {
                // TODO 自動生成されたメソッド・スタブ
                this.cxt = cxt;
                this.res = res;
 
                LinearLayout layout = new LinearLayout(cxt);
-               Button button = new Button(cxt);
+               layout.setLayoutParams(new LayoutParams(FP, WC));
+               layout.setOrientation(LinearLayout.VERTICAL);
+               
+               ImageView imageView = new ImageView(cxt);
+               imageView.setImageResource(R.drawable.question);
+               
+               LinearLayout selectBtnLayout = new LinearLayout(cxt);
+               selectBtnLayout.setOrientation(LinearLayout.HORIZONTAL);
+               selectBtnLayout.setLayoutParams(new LayoutParams(FP, FP));
+               selectBtnAllay = new Button[3];
+               
+               for(Button btn : selectBtnAllay){
+                       btn = new Button(cxt);
+                       btn.setOnClickListener(this);
+                       btn.setWidth(FP);
+                       btn.setHeight(WC);
+                       selectBtnLayout.addView(btn);
+               }
+               
+               submitBtn = new Button(cxt);
+               submitBtn.setText("Submit");
+               submitBtn.setOnClickListener(this);
 
-               layout.addView(button);
+               layout.addView(imageView);
+               layout.addView(selectBtnLayout);
+               layout.addView(submitBtn);
 
                return layout;
        }
@@ -30,4 +69,15 @@ public class CircuitTask extends BaseApp {
        protected void onClose() {
                super.onClose();
        }
+
+       @Override
+       public void onClick(View v) {
+               // TODO 自動生成されたメソッド・スタブ
+               if(v.equals(submitBtn)){
+                       Toast.makeText(cxt, "SUBMIT", Toast.LENGTH_LONG).show();
+               }else{
+                       Toast.makeText(cxt, "なんか押した?", Toast.LENGTH_LONG).show();
+               }
+       }
+       
 }