use of android.widget.TableLayout in project smoke by textbrowser.
the class Chat method prepareListeners.
private void prepareListeners() {
Button button1 = (Button) findViewById(R.id.call);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (Chat.this.isFinishing())
return;
StringBuilder stringBuilder = new StringBuilder();
TextView textView1 = (TextView) findViewById(R.id.chat_messages);
TableLayout tableLayout = (TableLayout) findViewById(R.id.participants);
int count = tableLayout.getChildCount();
for (int i = 0; i < count; i++) {
TableRow row = (TableRow) tableLayout.getChildAt(i);
if (row == null)
continue;
Switch switch1 = (Switch) row.getChildAt(0);
if (switch1 == null)
continue;
if (switch1.getTag() != null && switch1.isChecked()) {
boolean ok = Kernel.getInstance().call(switch1.getId(), ParticipantCall.Algorithms.RSA, switch1.getTag().toString());
stringBuilder.delete(0, stringBuilder.length());
stringBuilder.append("[");
stringBuilder.append(m_simpleDateFormat.format(new Date()));
stringBuilder.append("] ");
if (ok)
stringBuilder.append("Initiating a session with ");
else
stringBuilder.append("Smoke is currently attempting to " + "establish a session with ");
stringBuilder.append(nameFromCheckBoxText(switch1.getText().toString()));
stringBuilder.append(" (");
stringBuilder.append(Miscellaneous.prepareSipHashId(switch1.getTag().toString()));
stringBuilder.append("). ");
if (!ok) {
stringBuilder.append("Please try again in ");
stringBuilder.append(Kernel.getInstance().callTimeRemaining(switch1.getTag().toString()));
stringBuilder.append(" second(s).\n\n");
} else
stringBuilder.append("Please be patient.\n\n");
textView1.append(stringBuilder);
}
}
if (tableLayout.getChildCount() > 0) {
scrollMessagesView();
final TextView textView2 = (TextView) findViewById(R.id.chat_message);
textView2.post(new Runnable() {
@Override
public void run() {
textView2.requestFocus();
}
});
}
}
});
}
use of android.widget.TableLayout in project android_frameworks_base by AOSPA.
the class AddColumn method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.add_column_in_table);
final Button addRowButton = (Button) findViewById(R.id.add_row_button);
addRowButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final TableLayout table = (TableLayout) findViewById(R.id.table);
final TableRow newRow = new TableRow(AddColumn.this);
for (int i = 0; i < 4; i++) {
final TextView view = new TextView(AddColumn.this);
view.setText("Column " + (i + 1));
view.setPadding(3, 3, 3, 3);
newRow.addView(view, new TableRow.LayoutParams());
}
table.addView(newRow, new TableLayout.LayoutParams());
newRow.requestLayout();
}
});
}
use of android.widget.TableLayout in project android-diplicity by zond.
the class GameActivity method showGameStates.
public void showGameStates() {
hideAllExcept(R.id.game_state_view);
if (member == null) {
findViewById(R.id.edit_game_state_button).setVisibility(View.GONE);
}
handleReq(gameStateService.ListGameStates(game.ID), new Sendable<MultiContainer<GameState>>() {
@Override
public void send(MultiContainer<GameState> gameStateMultiContainer) {
GameState myState = null;
TableLayout mutedTable = (TableLayout) findViewById(R.id.muted_table);
mutedTable.removeAllViews();
FloatingActionButton button = ((FloatingActionButton) mutedTable.findViewById(R.id.open_button));
if (button != null) {
mutedTable.removeView(button);
}
final List<String> nations = new ArrayList<String>();
for (Member thisMember : game.Members) {
if (member == null || !thisMember.Nation.equals(member.Nation)) {
nations.add(thisMember.Nation);
}
GameState foundState = null;
for (SingleContainer<GameState> singleContainer : gameStateMultiContainer.Properties) {
if (singleContainer.Properties.Nation.equals(thisMember.Nation)) {
foundState = singleContainer.Properties;
}
}
if (member != null && thisMember.Nation.equals(member.Nation)) {
myState = foundState;
}
TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 1.0f);
int margin = getResources().getDimensionPixelSize(R.dimen.muted_table_margin);
params.bottomMargin = margin;
params.topMargin = margin;
params.leftMargin = margin;
params.rightMargin = margin;
TableRow tableRow = new TableRow(GameActivity.this);
tableRow.setLayoutParams(params);
LinearLayout playerSide = new LinearLayout(GameActivity.this);
LinearLayout.LayoutParams linearParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
playerSide.setLayoutParams(params);
playerSide.setOrientation(LinearLayout.VERTICAL);
UserView user = new UserView(GameActivity.this, null);
user.setUser(GameActivity.this, thisMember.User, true);
user.setLayoutParams(linearParams);
playerSide.addView(user);
TextView nation = new TextView(GameActivity.this);
nation.setText(thisMember.Nation);
nation.setLayoutParams(linearParams);
playerSide.addView(nation);
tableRow.addView(playerSide);
TextView muteds = new TextView(GameActivity.this);
muteds.setLayoutParams(params);
if (foundState != null && foundState.Muted != null) {
muteds.setText(TextUtils.join(", ", foundState.Muted));
} else {
muteds.setText("");
}
tableRow.addView(muteds);
mutedTable.addView(tableRow);
}
final GameState finalMyState = myState;
if (finalMyState != null) {
((FloatingActionButton) findViewById(R.id.edit_game_state_button)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final boolean[] checked = new boolean[nations.size()];
if (finalMyState.Muted != null) {
for (String muted : finalMyState.Muted) {
int pos = nations.indexOf(muted);
if (pos > -1) {
checked[pos] = true;
}
}
}
final AlertDialog dialog = new AlertDialog.Builder(GameActivity.this).setMultiChoiceItems(nations.toArray(new String[] {}), checked, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i, boolean b) {
checked[i] = b;
}
}).setTitle(R.string.muted).setPositiveButton(R.string.update, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int j) {
List<String> mutedMembers = new ArrayList<String>();
for (int i = 0; i < checked.length; i++) {
if (checked[i]) {
mutedMembers.add(nations.get(i));
}
}
Collections.sort(mutedMembers);
finalMyState.Muted = mutedMembers;
handleReq(gameStateService.GameStateUpdate(finalMyState, game.ID, finalMyState.Nation), new Sendable<SingleContainer<GameState>>() {
@Override
public void send(SingleContainer<GameState> gameStateSingleContainer) {
showGameStates();
}
}, getResources().getString(R.string.updating_game_state));
}
}).show();
}
});
}
}
}, getResources().getString(R.string.loading_game_settings));
}
use of android.widget.TableLayout in project SQLPractice by Gear61.
the class SandboxResultActivity method createTable.
public void createTable(String[] columns, String[][] data) {
TableLayout.LayoutParams dataParams = new TableLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 0.1f);
dataParams.setMargins(0, 0, 4, 0);
LinearLayout topRow = new LinearLayout(this);
for (String column : columns) {
TextView text = new TextView(this);
text.setText(column);
text.setLayoutParams(dataParams);
text.setTypeface(null, Typeface.BOLD);
topRow.addView(text);
}
topRow.setOrientation(LinearLayout.HORIZONTAL);
// Add the TableRow to the TableLayout
mResultTable.addView(topRow);
for (String[] dataRow : data) {
LinearLayout tuple = new LinearLayout(this);
for (String datum : dataRow) {
TextView text = new TextView(this);
text.setText(datum);
text.setLayoutParams(dataParams);
tuple.addView(text);
}
tuple.setOrientation(LinearLayout.HORIZONTAL);
mResultTable.addView(tuple);
}
}
use of android.widget.TableLayout in project opacclient by opacapp.
the class MultiStepResultHelper method askForConfirmation.
public void askForConfirmation(final MultiStepResult result) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
LayoutInflater inflater = context.getLayoutInflater();
View view = inflater.inflate(R.layout.dialog_reservation_details, null, false);
TableLayout table = (TableLayout) view.findViewById(R.id.tlDetails);
if (result.getDetails().size() == 1 && result.getDetails().get(0).length == 1) {
((ViewGroup) view.findViewById(R.id.rlConfirm)).removeView(table);
TextView tv = new TextView(context);
tv.setText(result.getDetails().get(0)[0]);
tv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
((ViewGroup) view.findViewById(R.id.rlConfirm)).addView(tv);
} else {
for (String[] detail : result.getDetails()) {
TableRow tr = new TableRow(context);
if (detail.length == 2) {
TextView tv1 = new TextView(context);
tv1.setText(Html.fromHtml(detail[0]));
tv1.setTypeface(null, Typeface.BOLD);
tv1.setPadding(0, 0, 8, 0);
TextView tv2 = new TextView(context);
tv2.setText(Html.fromHtml(detail[1]));
tv2.setEllipsize(TruncateAt.END);
tv2.setSingleLine(false);
tr.addView(tv1);
tr.addView(tv2);
} else if (detail.length == 1) {
TextView tv1 = new TextView(context);
tv1.setText(Html.fromHtml(detail[0]));
tv1.setPadding(0, 2, 0, 2);
TableRow.LayoutParams params = new TableRow.LayoutParams(0);
params.span = 2;
tv1.setLayoutParams(params);
tr.addView(tv1);
}
table.addView(tr);
}
}
builder.setTitle(R.string.confirm_title).setView(view).setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
doStep(MultiStepResult.ACTION_CONFIRMATION, "confirmed");
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
adialog.cancel();
if (callback != null) {
callback.onUserCancel();
}
}
});
adialog = builder.create();
adialog.show();
}
Aggregations