public void delRecord(Integer index, TableRow row1, TextView cp1) {
    final TextView cp = cp1;
    final Integer i = index;
    final TableRow row = row1;

    row.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            cp.setBackgroundResource(R.drawable.borders_black_and_darkblue);
            AlertDialog dialog =
                new AlertDialog.Builder(getContext())
                    .setTitle("刪除記錄?")
                    .setMessage("刪除記錄?")
                    .setPositiveButton(
                        android.R.string.yes,
                        new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int which) {
                            dataAdapter1.delWord(wordRecordArrayList.get(i).getC_id());
                            setWordList();
                          }
                        })
                    .setNegativeButton(
                        R.string.cancel,
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                            cp.setBackgroundResource(R.drawable.borders_black_and_blue);
                          }
                        })
                    .show();
            return false;
          }
        });
  }
Example #2
0
  private void TabloDoldur() {
    try {

      Integer count = 0;
      YeDatabase db = new YeDatabase(this);
      final ObDataBase yDb = new ObDataBase(this);
      db.open();
      final Cursor cursor = db.QueryTbDataBases();
      tlResults.removeAllViews();
      while (cursor.moveToNext()) {

        yDb.ID = cursor.getInt(0);
        yDb.Name = cursor.getString(1);
        yDb.Instance = cursor.getString(2);
        yDb.Ip = cursor.getString(3);
        yDb.Port = cursor.getString(4);
        yDb.User = cursor.getString(5);
        yDb.Pass = cursor.getString(6);
        yDb.InUse = cursor.getInt(7);
        yDb.Description = cursor.getString(8);

        LayoutInflater inflater =
            (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        TableRow tr = (TableRow) inflater.inflate(R.layout.satir, null);

        tr.setId(100 + count);
        tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

        TextView labelDesc = new TextView(this, null, R.style.BodyText);
        labelDesc.setId(200 + count);
        labelDesc.setText(yDb.Description);
        tr.addView(labelDesc);

        TextView labelIp = new TextView(this, null, R.style.BodyText);
        labelIp.setId(200 + count);
        labelIp.setText(yDb.Ip);
        tr.addView(labelIp);

        TextView labelName = new TextView(this);
        labelName.setId(200 + count);
        labelName.setText(yDb.Name);
        tr.addView(labelName);

        RadioButton labelInUse = new RadioButton(this);
        labelInUse.setId(200 + count);
        labelInUse.setTag(200 + "");
        labelInUse.setGravity(Gravity.CENTER_VERTICAL);
        labelInUse.setGravity(Gravity.CENTER_HORIZONTAL);
        labelInUse.setEnabled(false);

        // rdgActiveData.addView(labelInUse);
        if (yDb.InUse == 1) labelInUse.setChecked(true);
        else labelInUse.setChecked(false);

        tr.addView(labelInUse);

        tlResults.addView(
            tr, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        count++;

        tr.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View view) {
                DetayDoldur((TableRow) view);
              }
            });
        tr.setOnLongClickListener(
            new OnLongClickListener() {

              @Override
              public boolean onLongClick(View v) {
                SetAktifVeriTabani((TableRow) v);
                return true;
              }
            });
      }
    } catch (Exception e) {
      Toast.makeText(this, "detay göster" + e.getMessage(), Toast.LENGTH_LONG).show();
    }
  }