Exemplo n.º 1
0
 protected android.view.View onCreateDialogView() {
   android.widget.TableLayout.LayoutParams params;
   android.widget.TableLayout layout = new android.widget.TableLayout(mContext);
   layout.setPadding(6, 6, 6, 6);
   mSplashText = new android.widget.TextView(mContext);
   if (mDialogMessage != null) {
     mSplashText.setText(mDialogMessage);
   }
   android.widget.TableRow row_header = new android.widget.TableRow(mContext);
   row_header.addView(mSplashText);
   mPickInteger = new net.mandaria.tippytipper.widgets.NumberPicker(mContext);
   mPickInteger.setRange(mMin, mMax);
   android.widget.TextView suffix = new android.widget.TextView(mContext);
   suffix.setText(mSuffix);
   suffix.setTextSize(32);
   android.widget.TableRow row_one = new android.widget.TableRow(mContext);
   row_one.setGravity(Gravity.CENTER);
   row_one.addView(mPickInteger);
   row_one.addView(suffix);
   layout.addView(row_header);
   android.widget.TableLayout table_main = new android.widget.TableLayout(mContext);
   table_main.addView(row_one);
   android.widget.TableRow row_main = new android.widget.TableRow(mContext);
   row_main.setGravity(Gravity.CENTER_HORIZONTAL);
   row_main.addView(table_main);
   layout.addView(row_main);
   if (shouldPersist()) {
     mValue = getPersistedInt(mDefault);
   }
   bindData();
   return layout;
 }
Exemplo n.º 2
0
  // boolean selected = false;
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_game_menu);

    //		Canvas ca = new Canvas();
    //		Paint p = new Paint();
    //		p.setAntiAlias(true);
    //		p.setStyle(Style.STROKE);
    //		p.setStrokeWidth(5);

    TestCanvas tcanvas = new TestCanvas(this);
    Canvas canvas = new Canvas();
    tcanvas.draw(canvas);

    TableLayout layout = new TableLayout(this);
    layout.setLayoutParams(new TableLayout.LayoutParams(4, 5));

    layout.setPadding(0, 0, 50, 50);
    layout.addView((View) tcanvas);

    for (int f = 0; f < 5; f++) {
      TableRow tr = new TableRow(this);
      for (int c = 0; c < 5; c++) {
        buttons[f][c] = new Cell(this);
        buttons[f][c].setWidth(10);
        buttons[f][c].setHeight(10);
        buttons[f][c].setBackgroundColor(Color.BLACK);
        buttons[f][c].setOnClickListener(this);
        Log.i(
            "button width[" + f + "] [" + c + "] = " + "" + buttons[f][c].getWidth(),
            ("" + buttons[f][c].getWidth()));
        Log.i(
            "button height[" + f + "] [" + c + "] = " + "" + buttons[f][c].getWidth(),
            ("" + buttons[f][c].getHeight()));
        // ca.drawLine(startX, startY, stopX, stopY, p);
        tr.addView(buttons[f][c], 50, 50);
      }
      layout.addView(tr);
    }
    Button b = new Button(this);
    super.setContentView(layout);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_card_add_user_hobby);
    Intent intent = getIntent();
    String hobby = intent.getStringExtra(CardEditActivity.EDIT_HOBBY_STR);
    String[] hobbys = hobby.split(";|£º| ");
    Map<String, Boolean> hobbymap = new HashMap<String, Boolean>();
    for (String item : hobbys) {
      hobbymap.put(item, false);
    }
    LayoutInflater inflater = LayoutInflater.from(CardAddUserHobbyActivity.this);
    TableLayout tl = (TableLayout) findViewById(R.id.tableLayout);
    this.width = DeviceInfoUtil.getDeviceCsw(getApplicationContext());
    this.times = DeviceInfoUtil.getDeviceCsd(getApplicationContext());
    padding = (int) (padding * times);
    baseMargin = (int) (baseMargin * times);
    int restWidth = width - 2 * padding - 3 * baseMargin;
    int widthOne = restWidth / 4;
    baseMargin = (int) ((restWidth - widthOne * 4) / 3) + baseMargin;
    tl.setPadding(padding, 0, padding, 0);
    String[] items = getResources().getStringArray(R.array.array_hobby);
    TableRow tr = null;
    for (int i = 0; i < items.length; i++) {
      if (i % 4 == 0) {
        tr = new TableRow(CardAddUserHobbyActivity.this);
        tl.addView(tr);
      }
      ToggleButton tb = (ToggleButton) inflater.inflate(R.layout.item_toggle, null);
      tb.setText(items[i]);
      tb.setTextOn(items[i]);
      tb.setTextOff(items[i]);
      tb.setOnCheckedChangeListener(
          new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (isChecked) {
                buttonView.setTextColor(Color.rgb(0, 72, 255));
                selected.put(buttonView.getText().toString(), true);
              } else {
                buttonView.setTextColor(Color.rgb(52, 52, 52));
                selected.put(buttonView.getText().toString(), false);
              }
            }
          });
      tr.addView(tb);
      TableRow.LayoutParams trlp =
          new TableRow.LayoutParams(widthOne, TableRow.LayoutParams.WRAP_CONTENT);
      trlp.rightMargin = baseMargin;
      trlp.bottomMargin = baseMargin * 3 / 8;
      trlp.topMargin = baseMargin * 3 / 8;
      tb.setLayoutParams(trlp);
      if (hobbymap.containsKey(items[i])) {
        tb.setChecked(true);
        hobbymap.put(items[i], true);
        selected.put(items[i], true);
      } else {
        selected.put(items[i], false);
      }
    }
    String hobbyStr = "";
    for (String item : hobbymap.keySet()) {
      if (!hobbymap.get(item)) {
        hobbyStr += item + " ";
      }
    }
    ((EditText) findViewById(R.id.editText)).setText(hobbyStr);
    initClick();
  }
Exemplo n.º 4
0
  public void setTableLayout() {
    LinearLayout ll_profile = (LinearLayout) findViewById(R.id.ll_profile);

    TableLayout tl;
    TableRow tr;
    TextView tv;

    tl = new TableLayout(this);
    CustomStructure.addTR4TD("닉네임", pp.player_name, "LR2ID", pp.player_lr2id, tl, this);
    CustomStructure.addTR4TD("플레이곡수", pp.player_songcnt, "플레이횟수", pp.player_playcnt, tl, this);
    CustomStructure.addTR2TD("단위인정", pp.player_sp, tl, this);
    tl.setStretchAllColumns(true);
    tl.setPadding(0, 0, 0, 20);
    ll_profile.addView(tl);

    // self Introduce
    tv = new TextView(this);
    tv.setBackgroundColor(CustomStructure.clr_title);
    tv.setText(Html.fromHtml("<b>자기소개</b>"));
    tv.setPadding(10, 10, 10, 10);
    ll_profile.addView(tv);
    tv = new TextView(this);
    tv.setBackgroundColor(CustomStructure.clr_data);
    tv.setText(pp.player_self);
    tv.setPadding(10, 10, 10, 10);
    ll_profile.addView(tv);

    // homepage
    if (!pp.player_homepage.equals("")) {
      tv = new TextView(this);
      tv.setText("홈페이지 : " + pp.player_homepage);
      tv.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              CustomStructure.gotoURI(v.getContext(), pp.player_homepage);
            }
          });
      tv.setPadding(10, 10, 10, 10);
      ll_profile.addView(tv);
    }

    // Rival
    tl = new TableLayout(this);
    tr = new TableRow(this);
    tv = new TextView(this);
    tv.setText(Html.fromHtml("<b>라이벌</b>"));
    tv.setPadding(10, 5, 10, 5);
    tv.setBackgroundColor(CustomStructure.clr_title);
    tr.addView(tv); // space
    tl.addView(tr);
    final Context _c = this;
    for (int i = 0; i < pp.player_rival_cnt; i++) {
      tr = new TableRow(this);
      tv = new TextView(this);
      tv.setText(pp.player_rival[i]);
      tv.setPadding(10, 5, 10, 5);
      tv.setBackgroundColor(CustomStructure.clr_data);
      final String s1 = pp.player_rival[i];
      final String s2 = pp.player_rival_uri[i];
      tv.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              // intent 처리
              Activity_Profile.user_name = s1;
              Activity_Profile.user_uri = s2;
              startActivity(new Intent(_c, Activity_Profile.class));
            }
          });
      tr.addView(tv);
      tl.addView(tr);
    }
    tl.setStretchAllColumns(true);
    tl.setPadding(0, 20, 0, 20);
    ll_profile.addView(tl);

    tl = new TableLayout(this);
    CustomStructure.addTR2TD("FULLCOMBO", pp.player_clear[0], tl, this);
    CustomStructure.addTR2TD("HARD", pp.player_clear[1], tl, this);
    CustomStructure.addTR2TD("NORMAL", pp.player_clear[2], tl, this);
    CustomStructure.addTR2TD("EASY", pp.player_clear[3], tl, this);
    CustomStructure.addTR2TD("FAILED", pp.player_clear[4], tl, this);
    tl.setStretchAllColumns(true);
    tl.setPadding(0, 0, 0, 20);
    ll_profile.addView(tl);

    Button b = new Button(this);
    b.setText("랭킹창 열기/닫기 (토글)");
    b.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            ScrollView sv = (ScrollView) findViewById(R.id.scrollView1);
            LinearLayout ll1 = (LinearLayout) findViewById(R.id.linearLayout1);
            LinearLayout ll2 = (LinearLayout) findViewById(R.id.linearLayout2);
            if (!isDetail) {
              LayoutParams param = sv.getLayoutParams();
              param.height = 180;
              sv.setLayoutParams(param);
              ll1.setVisibility(View.VISIBLE);
              ll2.setVisibility(View.VISIBLE);
            } else {
              LayoutParams param = sv.getLayoutParams();
              param.height = LayoutParams.MATCH_PARENT;
              sv.setLayoutParams(param);
              ll1.setVisibility(View.GONE);
              ll2.setVisibility(View.GONE);
            }
            isDetail = !isDetail;
          }
        });
    ll_profile.addView(b);
  }
Exemplo n.º 5
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   try { // try to get matrix config
     String fname = "battleship";
     File file = getBaseContext().getFileStreamPath(fname);
     if (file.exists()) { // read from file
       DataInputStream in = new DataInputStream(openFileInput(fname));
       for (int i = 0; i < 10; i++) {
         for (int j = 0; j < 10; j++) {
           P1[i][j] = Integer.parseInt(in.readUTF());
         }
       }
       for (int i = 0; i < 10; i++) {
         for (int j = 0; j < 10; j++) {
           P2[i][j] = Integer.parseInt(in.readUTF());
         }
       }
       in.close();
     }
   } catch (IOException e) {
     Log.i("Data Input Sample", "I/O Error");
   }
   RelativeLayout hugelay = new RelativeLayout(this);
   ScrollView largelay = new ScrollView(this);
   largelay.setId(10000);
   TableLayout layout = new TableLayout(this);
   layout.setLayoutParams(new TableLayout.LayoutParams(300, 300));
   layout.setPadding(1, 1, 1, 1);
   int i, j;
   for (i = 0; i <= 9; i++) {
     TableRow tr = new TableRow(this);
     for (j = 0; j <= 9; j++) {
       ImageButton b = new ImageButton(this);
       if (P2[i][j] == 0) {
         b.setImageResource(R.drawable.water);
       } else if (P2[i][j] == 99) {
         b.setImageResource(R.drawable.explosion);
       } else if (P2[i][j] == 88) {
         b.setImageResource(R.drawable.x);
       } else {
         b.setImageResource(R.drawable.water2);
       }
       b.setId(i * 10 + j);
       b.setOnClickListener(this);
       tr.addView(b, 72, 72);
     } // for
     layout.addView(tr);
   } // for
   largelay.addView(layout);
   hugelay.setBackgroundResource(R.drawable.battleshipbg);
   Button btn = new Button(this);
   btn.setText("MY MAP");
   btn.setBackgroundResource(R.color.transparent);
   btn.setHeight(134);
   btn.setWidth(134);
   btn.setId(1000);
   btn.setOnClickListener(this);
   RelativeLayout.LayoutParams lp =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
   lp.addRule(RelativeLayout.RIGHT_OF, largelay.getId());
   lp.addRule(RelativeLayout.CENTER_VERTICAL);
   hugelay.addView(largelay);
   hugelay.addView(btn, lp);
   super.setContentView(hugelay);
 } // ()