/// <summary> /// Initializes the layout of the game by inserting the row-templates into the table, setting the values of the /// layout-elements and applying click-events to the buttons. /// </summary> /// <param name="level">Level.</param> private void initGameLayout(int level) { if (level == 3) { for (int i = 0; i < level; i++) { View newRow = LayoutInflater.From(this).Inflate(Resource.Drawable.ThreeGame, null, false); gameTable.AddView(newRow); } View row1 = gameTable.GetChildAt(0); View row2 = gameTable.GetChildAt(1); View row3 = gameTable.GetChildAt(2); but1_1 = row1.FindViewById <Button> (Resource.Id.Three_1); but1_2 = row1.FindViewById <Button> (Resource.Id.Three_2); but1_3 = row1.FindViewById <Button> (Resource.Id.Three_3); but2_1 = row2.FindViewById <Button> (Resource.Id.Three_1); but2_2 = row2.FindViewById <Button> (Resource.Id.Three_2); but2_3 = row2.FindViewById <Button> (Resource.Id.Three_3); but3_1 = row3.FindViewById <Button> (Resource.Id.Three_1); but3_2 = row3.FindViewById <Button> (Resource.Id.Three_2); but3_3 = row3.FindViewById <Button> (Resource.Id.Three_3); buttonList.Add(but1_1); buttonList.Add(but1_2); buttonList.Add(but1_3); buttonList.Add(but2_1); buttonList.Add(but2_2); buttonList.Add(but2_3); buttonList.Add(but3_1); buttonList.Add(but3_2); buttonList.Add(but3_3); but1_1.Click += delegate { clickEvent(but1_1, 0); }; but1_2.Click += delegate { clickEvent(but1_2, 1); }; but1_3.Click += delegate { clickEvent(but1_3, 2); }; but2_1.Click += delegate { clickEvent(but2_1, 3); }; but2_2.Click += delegate { clickEvent(but2_2, 4); }; but2_3.Click += delegate { clickEvent(but2_3, 5); }; but3_1.Click += delegate { clickEvent(but3_1, 6); }; but3_2.Click += delegate { clickEvent(but3_2, 7); }; but3_3.Click += delegate { clickEvent(but3_3, 8); }; pauseButton.Click += delegate { pauseGame(paused); }; } }
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) { View v = inflater.Inflate(Resource.Layout.fragment_remote_control, container, false); mSelectedTextView = v.FindViewById <TextView>(Resource.Id.fragment_remote_control_selectedTextView); mWorkingTextView = v.FindViewById <TextView>(Resource.Id.fragment_remote_control_workingTextView); TableLayout tableLayout = v.FindViewById <TableLayout>(Resource.Id.fragment_remote_control_tableLayout); int number = 1; for (int i = 2; i < tableLayout.ChildCount - 1; i++) { TableRow row = (TableRow)tableLayout.GetChildAt(i); for (int j = 0; j < row.ChildCount; j++) { Button button = (Button)row.GetChildAt(j); button.Text = number.ToString(); button.SetOnClickListener(this); number++; } } TableRow bottomRow = (TableRow)tableLayout.GetChildAt(tableLayout.ChildCount - 1); Button deleteButton = (Button)bottomRow.GetChildAt(0); deleteButton.Text = "Delete"; deleteButton.SetTextAppearance(RemoteControlActivity.Context, Resource.Style.RemoteButton_ActionButton); deleteButton.Click += (object sender, EventArgs e) => { mWorkingTextView.Text = "0"; }; Button zeroButton = (Button)bottomRow.GetChildAt(1); zeroButton.Text = "0"; zeroButton.SetOnClickListener(this); Button enterButton = (Button)bottomRow.GetChildAt(2); enterButton.Text = "Enter"; enterButton.SetTextAppearance(RemoteControlActivity.Context, Resource.Style.RemoteButton_ActionButton); enterButton.Click += (object sender, EventArgs e) => { Console.WriteLine("Enter Button Clicked"); string working = mWorkingTextView.Text; if (working.Length > 0) { mSelectedTextView.Text = working; } mWorkingTextView.Text = "0"; }; return(v); }
public void game_area_load()//itt csak feltöltöm a sorokat a táblázatban üres gombokkal, hogy meg legyen az alakja a táblázatnak(így illeszkedni fog a telefon nagyságához) { game_Buttons = new FrameLayout[a_side, a_side]; for (int i = 0; i < game_area_tableLayout.ChildCount; i++) { TableRow tableRow = (TableRow)game_area_tableLayout.GetChildAt(i); for (int j = 0; j < a_side; j++) { game_button game_Button = new game_button(parent_context, 0, information_Container, a_side); tableRow.AddView(game_Button.Get_game_Button(), j); tableRow.GetChildAt(j).SetBackgroundColor(Color.Gray); game_Buttons[i, j] = (FrameLayout)tableRow.GetChildAt(j); } } }
private void GenerateBoardButtonsID() { Context applicationContext = Application.Context; TableRow viewTableRow = null; View gameRowView = null; int iIdTile = 0; ImageButton imageButton; for (int iRowIterator = 0; iRowIterator < _gameBoardTableLayout.ChildCount; iRowIterator++) { gameRowView = _gameBoardTableLayout.GetChildAt(iRowIterator); if (gameRowView != null && (gameRowView is TableRow)) { viewTableRow = (TableRow)gameRowView; for (int iTabRowChildIterator = 0; iTabRowChildIterator < viewTableRow.ChildCount; iTabRowChildIterator++) { imageButton = (ImageButton)viewTableRow.GetChildAt(iTabRowChildIterator); imageButton.Id = iIdTile; _gameBoardDictionary.Add(iIdTile, GameButtonStates.Standard); iIdTile++; } } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_results); Android.Support.V7.App.ActionBar actionBar = SupportActionBar; if (actionBar != null) { actionBar.SetDisplayHomeAsUpEnabled(true); } TableLayout tl = FindViewById <TableLayout>(Resource.Id.tablelayout_contents); TableRow tr; TextView tv; List <string[]> data = ReadData(); foreach (string[] row in data) { tr = new TableRow(this); foreach (string cell in row) { tv = new TextView(this); tv.Background = ContextCompat.GetDrawable(this, Android.Resource.Drawable.EditBoxBackground); tv.Text = cell; tr.AddView(tv); } tl.AddView(tr); } string[] header = Resources.GetStringArray(Resource.Array.results_headers); tr = FindViewById <TableRow>(Resource.Id.tablerow_header); foreach (string cell in header) { tv = new TextView(this) { Background = ContextCompat.GetDrawable(this, Android.Resource.Drawable.EditBoxBackground), Text = cell }; tr.AddView(tv); } tl.ViewTreeObserver.GlobalLayout += (sender, args) => { TableRow trH; TextView tvH; trH = FindViewById <TableRow>(Resource.Id.tablerow_header); // if (tl.ChildCount > 0) for (int i = 0; i < tl.ChildCount; i++) { // tr = (TableRow)tl.GetChildAt(0); tr = (TableRow)tl.GetChildAt(i); for (int j = 0; j < tr.ChildCount; j++) { tv = (TextView)tr.GetChildAt(j); tvH = (TextView)trH.GetChildAt(j); tvH.SetWidth(tv.Width); } } }; }
game_area_load() //itt csak feltöltöm a sorokat a táblázatban üres gombokkal, hogy meg legyen az alakja a táblázatnak(így illeszkedni fog a telefon nagyságához) { _gameButtons = new FrameLayout[_aSide, _aSide]; for (var i = 0; i < _gameAreaTableLayout.ChildCount; i++) { var tableRow = (TableRow)_gameAreaTableLayout.GetChildAt(i); for (var j = 0; j < _aSide; j++) { var gameButton = new GameButton(_parentContext, 0, _aSide); tableRow.AddView(gameButton.Get_game_Button(), j); var btnBorder = (FrameLayout)tableRow.GetChildAt(j); btnBorder.GetChildAt(0).SetBackgroundColor(Color.Gray); _gameButtons[i, j] = (FrameLayout)tableRow.GetChildAt(j); } } }
private void SetLocationRequest(LocationRequest request) { TableLayout table = FindViewById <TableLayout>(Resource.Id.callback_table_layout_show); Dictionary <string, string> paramList = new Dictionary <string, string>(); TableRow[] rows = new TableRow[table.ChildCount]; for (int i = 0; i < rows.Length; i++) { rows[i] = (TableRow)table.GetChildAt(i); paramList[((TextView)rows[i].GetChildAt(0)).Text] = ((EditText)rows[i].GetChildAt(1)).Text; } request.SetPriority(int.Parse(paramList[LocationRequestConstants.Priority])); request.SetInterval(long.Parse(paramList[LocationRequestConstants.Interval])); request.SetFastestInterval(long.Parse(paramList[LocationRequestConstants.FastestInterval])); request.SetExpirationTime(long.Parse(paramList[LocationRequestConstants.ExpirationTime])); request.SetExpirationDuration(long.Parse(paramList[LocationRequestConstants.ExpirationDuration])); request.SetNumUpdates(int.Parse(paramList[LocationRequestConstants.NumUpdates])); request.SetSmallestDisplacement(float.Parse(paramList[LocationRequestConstants.SmallestDisplacement])); request.SetMaxWaitTime(long.Parse(paramList[LocationRequestConstants.MaxWaitTime])); request.SetNeedAddress(bool.Parse(paramList[LocationRequestConstants.NeedAddress])); request.SetLanguage(paramList[LocationRequestConstants.Language]); request.SetCountryCode(paramList[LocationRequestConstants.CountryCode]); }
private void AttachEventHandlers(TableLayout fbxTeleco) { string path = "Everson Mono Bold.ttf"; Typeface tf = Typeface.CreateFromAsset(Assets, path); for (int i = 0; i < fbxTeleco.ChildCount; i++) { var row = fbxTeleco.GetChildAt(i) as TableRow; if (row == null) { continue; } for (int j = 0; j < row.ChildCount; j++) { var btnView = row.GetChildAt(j) as Android.Widget.Button; btnView.Click += BtnView_Click; btnView.LongClick += BtnView_LongClick; btnView.Typeface = tf; } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); // changing CultureInfo to en-GB to show decimal point as "." instead of "," Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); // creating an array of 36 TextViews used for storing every cell from TableLayout int textViewCount = 36; textViewArray = new TextView[textViewCount]; // assigning resources to local variables Spinner spinner = FindViewById <Spinner>(Resource.Id.spinnerPrimaryType); Spinner spinner2 = FindViewById <Spinner>(Resource.Id.spinnerSecondaryType); Button showDmgButton = FindViewById <Button>(Resource.Id.showDmgButton); TableLayout tableLayout1 = FindViewById <TableLayout>(Resource.Id.tableLayout1); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); // filling textViewArray with TextViews from TableLayout int y = 0; for (int i = 1; i < tableLayout1.ChildCount; i++) { View child = tableLayout1.GetChildAt(i); if (child is TableRow row) { for (int x = 0; x < row.ChildCount; x++) { View view = row.GetChildAt(x); textViewArray[y] = (TextView)view; ++y; } } } // restoring saved data when screen orientation is changed if (savedInstanceState != null) { string[] temp = savedInstanceState.GetStringArray("savedArray"); int[] tempColors = savedInstanceState.GetIntArray("savedColors"); selectedSorting = savedInstanceState.GetInt("savedSorting"); for (int d = 0; d < 36; d++) { textViewArray[d].Text = temp[d]; Android.Graphics.Color backgroundColor = new Android.Graphics.Color(tempColors[d]); textViewArray[d].SetBackgroundColor(backgroundColor); } if (temp[0] != "") { tableLayout1.SetColumnCollapsed(0, false); tableLayout1.SetColumnCollapsed(1, false); } } // creating 2 custom spinner adapters and assigning them to the primary and secondary pokemon type spinners ColorfulSpinnerAdapter adapter = new ColorfulSpinnerAdapter(this, Resource.Array.pokemonType, Resource.Layout.spinner_item); ColorfulSpinnerAdapter adapter2 = new ColorfulSpinnerAdapter(this, Resource.Array.pokemonType, Resource.Layout.spinner_item); spinner.Adapter = adapter; spinner2.Adapter = adapter2; // creating local variables used for filling TextViews string type1 = string.Empty; string type2 = string.Empty; TypeCalculator dmgCalc = new TypeCalculator(); PkmnType[] typez; PkmnType[] typez2; showDmgButton.Click += (sender, e) => { // checks spinner content type1 = spinner.SelectedItem.ToString(); type2 = spinner2.SelectedItem.ToString(); // check if one of chosen types is (none) if (string.Equals(type1, Resources.GetString(Resource.String.notype))) { if (string.Equals(type2, Resources.GetString(Resource.String.notype))) { // fill TextViews of TableLayout with empty strings if both chosen types are (none) for (int d = 0; d < textViewCount; d++) { textViewArray[d].Text = ""; } // hide table tableLayout1.SetColumnCollapsed(0, true); tableLayout1.SetColumnCollapsed(1, true); } else { // if the secondary type is not (none) check type and start filling table with sorted values typez = dmgCalc.CheckType(type2); // check selected sorting option if (selectedSorting == menu.GetItem(2).ItemId) { typez = dmgCalc.SortPkmnTypes(typez); } else if (selectedSorting == menu.GetItem(1).ItemId) { typez = dmgCalc.SortPkmnTypesByName(typez); } for (int d = 0, t = 0; d < textViewCount - 1; d += 2, t++) { textViewArray[d].Text = typez[t].TypeName; textViewArray[d].SetBackgroundColor(typez[t].TypeColor); textViewArray[d + 1].SetBackgroundColor(typez[t].TypeColor); textViewArray[d + 1].Text = typez[t].DmgTaken.ToString() + "x"; } // show table tableLayout1.SetColumnCollapsed(0, false); tableLayout1.SetColumnCollapsed(1, false); } } else { // if secondary type equals (none) or both types are the same check only primary type dmg multipliers if (string.Equals(type2, Resources.GetString(Resource.String.notype)) || string.Equals(type2, type1)) { typez = dmgCalc.CheckType(type1); // check selected sorting option if (selectedSorting == menu.GetItem(2).ItemId) { typez = dmgCalc.SortPkmnTypes(typez); } else if (selectedSorting == menu.GetItem(1).ItemId) { typez = dmgCalc.SortPkmnTypesByName(typez); } for (int d = 0, t = 0; d < textViewCount - 1; d += 2, t++) { textViewArray[d].Text = typez[t].TypeName; textViewArray[d].SetBackgroundColor(typez[t].TypeColor); textViewArray[d + 1].SetBackgroundColor(typez[t].TypeColor); textViewArray[d + 1].Text = typez[t].DmgTaken.ToString() + "x"; } } else { // if both types are different and none of them equals (none) check both types and // multiply primary type multipliers by secondary type multipliers typez = dmgCalc.CheckType(type1); typez2 = dmgCalc.CheckType(type2); for (int i = 0; i < 18; ++i) { typez[i].DmgTaken *= typez2[i].DmgTaken; } // check selected sorting option if (selectedSorting == menu.GetItem(2).ItemId) { typez = dmgCalc.SortPkmnTypes(typez); } else if (selectedSorting == menu.GetItem(1).ItemId) { typez = dmgCalc.SortPkmnTypesByName(typez); } for (int d = 0, t = 0; d < textViewCount - 1; d += 2, t++) { textViewArray[d].Text = typez[t].TypeName; textViewArray[d].SetBackgroundColor(typez[t].TypeColor); textViewArray[d + 1].SetBackgroundColor(typez[t].TypeColor); textViewArray[d + 1].Text = typez[t].DmgTaken.ToString() + "x"; } } tableLayout1.SetColumnCollapsed(0, false); tableLayout1.SetColumnCollapsed(1, false); } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.BellSchedule); Spinner daySpinner = FindViewById <Spinner>(Resource.Id.daySpinner); table = FindViewById <TableLayout>(Resource.Id.scheduleTable); //Set up spacing and alignment for text in table for (int i = 0; i < table.ChildCount; i++) { TableRow row = (TableRow)table.GetChildAt(i); //15 px above and below each row row.SetPadding(0, 15, 0, 15); //Center everything in the row for (int j = 0; j < 3; j++) { ((TextView)row.GetChildAt(j)).Gravity = GravityFlags.CenterHorizontal; } } daySpinner.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, BellSchedule.days.Keys.ToArray()); //Set advisory for Wednesday if (DateTime.Now.DayOfWeek == DayOfWeek.Wednesday) { daySpinner.SetSelection(1); } else { daySpinner.SetSelection(0); } daySpinner.ItemSelected += (object sender, Spinner.ItemSelectedEventArgs e) => { FindViewById <TextView>(Resource.Id.titleText).Text = "Today is " + MainActivity.aOrAn(daySpinner.SelectedItem.ToString()); //Get formated list of period start and end times List <Period> periods = BellSchedule.getSchedule(daySpinner.SelectedItem.ToString()); for (int i = 0; i < table.ChildCount - 1; i++) { TableRow row = (TableRow)table.GetChildAt(i + 1); //Set text to times, or clear if extra rows are not needed if (i < periods.Count) { ((TextView)row.GetChildAt(0)).Text = periods[i].Name; ((TextView)row.GetChildAt(1)).Text = periods[i].startTime; ((TextView)row.GetChildAt(2)).Text = periods[i].endTime; //Highlight current period if (DateTime.Now > DateTime.Parse(periods[i].startTime) && DateTime.Now < DateTime.Parse(periods[i].endTime)) { row.SetBackgroundColor(Color.Navy); } else { row.SetBackgroundColor(Color.Transparent); } } else { for (int j = 0; j < 3; j++) { ((TextView)row.GetChildAt(j)).Text = ""; } } } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.TopScores); UserDatabaseController databaseController = new UserDatabaseController(); PageController pageController = new PageController(this); int UserId = Intent.Extras.GetInt(Common.USERID); Button menuButton = FindViewById <Button>(Resource.Id.menuButton); TableLayout highScoresTable = FindViewById <TableLayout>(Resource.Id.highScoresTable); int tableLength = highScoresTable.ChildCount - 1; Game[] bestGames = new Game[tableLength]; List <Game> allGames = databaseController.GetGames(); fillTable(); /// <summary> /// Fills the table with top5 games by locating and removing the best games one by one from a local /// list containing all the games. /// </summary> void fillTable() { TextView Name; TextView HighScore; TableRow tableRow; for (int i = 0; i < tableLength; i++) { Game bestGame = findBestGame(); if (bestGame.FinalScore == 0) { break; } allGames.Remove(bestGame); User user = databaseController.GetUser(bestGame.UserId); tableRow = (TableRow)highScoresTable.GetChildAt(i + 1); Name = (TextView)(tableRow.GetChildAt(1)); Name.Text = user.UserName; Name.SetTextColor(Android.Graphics.Color.Black); HighScore = (TextView)(tableRow.GetChildAt(2)); HighScore.Text = bestGame.FinalScore.ToString(); HighScore.SetTextColor(Android.Graphics.Color.Black); } } /// <summary> /// Finds the best game. /// </summary> /// <returns>The best game.</returns> Game findBestGame() { Game bestGame = new Game(); foreach (Game game in allGames) { if (game.FinalScore > bestGame.FinalScore) { bestGame = game; } } return(bestGame); } menuButton.Click += (sender, e) => { pageController.GotoPage(typeof(MenuActivity), UserId, Common.USERID); }; }