/** @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem) */ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0: // Go back to the map page finish(); return true; case 1: // Sort the list by job title for (View vw : lstTable) { tblJobs.removeView(vw); } fillData(JobsCursor.SortBy.title); return true; case 2: // Sort the list by employer name for (View vw : lstTable) { tblJobs.removeView(vw); } fillData(JobsCursor.SortBy.employer_name); return true; case 3: // Add a new job Intent i = new Intent(MicroJobsList.this, AddJob.class); startActivity(i); return true; } return false; }
private void newGame(int c, int r) { ROW_COUNT = r; COL_COUNT = c; cards = new int[COL_COUNT][ROW_COUNT]; mainTable.removeView(findViewById(R.id.TableRow01)); mainTable.removeView(findViewById(R.id.TableRow02)); TableRow tr = ((TableRow) findViewById(R.id.TableRow03)); tr.removeAllViews(); mainTable = new TableLayout(context); tr.addView(mainTable); for (int y = 0; y < ROW_COUNT; y++) { mainTable.addView(createRow(y)); } firstCard = null; loadCards(); turns = 0; ((TextView) findViewById(R.id.tv1)).setText("ចននបកលង: " + turns); }
@Override public void onClick(View v) { for (View vw : lstTable) { tblJobs.removeView(vw); } fillData(JobsCursor.SortBy.employer_name); }
@Override public void onClick(View v) { // Remove any TextViews we added to the Table for (View vw : lstTable) { tblJobs.removeView(vw); } fillData(JobsCursor.SortBy.title); }
public void onClick(View v) { ViewGroup container = (ViewGroup) v.getParent(); TextView titleView = (TextView) container.getChildAt(0); String title = titleView.getText() + ""; SharedPreferences.Editor preferencesEditor = favoritespref.edit(); for (int i = 0; i < favorites.length; i++) { try { JSONObject total = new JSONObject(favorites[i]); JSONObject intermediate = total.getJSONObject("im:name"); String appname = intermediate.getString("label"); if (appname.compareTo(title) == 0) { preferencesEditor.remove(favorites[i]); preferencesEditor.apply(); // favorites = null; break; } } catch (JSONException e) { e.printStackTrace(); } } head.removeView(container); }
/** * Novo m�todo para criar o painel din�mico para os bot�es de selec��o da turma * * @author Thiago */ @SuppressLint("NewApi") private void makeTabela() { // Cria o objecto da base de dados LetrinhasDB db = new LetrinhasDB(this); // ************* Mudar este select de all para por ID de turma // (ALEXANDRE!!) List<Estudante> alunos = db.getAllStudentsByTurmaId(idTurma); // ******************************************************************************* int nAlunos = alunos.size(); int[] idAluno = new int[nAlunos]; String nomeAluno[] = new String[nAlunos]; String fotoAluno[] = new String[nAlunos]; // preenche os arrays s� com a informa��o necess�ria for (int i = 0; i < nAlunos; i++) { idAluno[i] = alunos.get(i).getIdEstudante(); nomeAluno[i] = alunos.get(i).getNome(); fotoAluno[i] = alunos.get(i).getNomefoto(); } for (Estudante cn : alunos) { String storage = cn.getNome() + "," + cn.getIdEstudante() + "," + cn.getNomefoto() + "," + cn.getEstado() + "," + cn.getIdTurma(); Log.d("letrinhas-Alunos", storage.toString()); } /** Scroll view com uma tabela de 4 colunas(max) */ // tabela a editar TableLayout tabela = (TableLayout) findViewById(R.id.tblEscolheAl); // linha da tabela a editar TableRow linha = (TableRow) findViewById(R.id.escAllinha01); // 1� bot�o Button bt = (Button) findViewById(R.id.AlBtOriginal); bt.setText("teste alunos"); // Contador de controlo int cont = 0; // criar o n� de linhas a dividir por 4 colunas for (int i = 0; i < nAlunos / 4; i++) { // nova linha da tabela TableRow linha1 = new TableRow(getBaseContext()); // Copiar os parametros da 1� linha linha1.setLayoutParams(linha.getLayoutParams()); // criar os 4 bot�es da linha for (int j = 0; j < 4; j++) { // ********************************** // Nome, id e foto do aluno final String alumni = nomeAluno[cont]; final int idAL = idAluno[cont]; final String alunFot = fotoAluno[cont]; // *********************************** // novo bot�o Button bt1 = new Button(bt.getContext()); // copiar os parametros do bot�o original bt1.setLayoutParams(bt.getLayoutParams()); // se o aluno tiver foto, vou busca-la if (fotoAluno[cont] != null) { String imageInSD = Environment.getExternalStorageDirectory().getAbsolutePath() + "/School-Data/Students/" + fotoAluno[cont]; Bitmap bitmap = BitmapFactory.decodeFile(imageInSD); ImageView imageView = new ImageView(this); // ajustar o tamanho da imagem imageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 210, 200, false)); // enviar para o bot�o bt1.setCompoundDrawablesWithIntrinsicBounds(null, imageView.getDrawable(), null, null); } else { // sen�o copia a imagem do bot�o original bt1.setCompoundDrawables(null, bt.getCompoundDrawablesRelative()[1], null, null); } // addicionar o nome bt1.setText(nomeAluno[cont]); // Defenir o que faz o bot�o ao clicar bt1.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { // Entrar na activity Bundle wrap = new Bundle(); wrap.putString("Escola", Escola); wrap.putInt("Escola_ID", idEscola); wrap.putString("Professor", Professor); wrap.putInt("Professor_ID", idProfessor); wrap.putString("Foto_professor", FotoProf); wrap.putString("Turma", Turma); wrap.putInt("Turma_ID", idTurma); wrap.putString("Aluno", alumni); wrap.putInt("Aluno_ID", idAL); wrap.putString("Foto_Aluno", alunFot); Intent it = new Intent(getApplicationContext(), EscModo.class); it.putExtras(wrap); startActivity(it); } }); // inserir o bot�o na linha linha1.addView(bt1); // incrementar o contador de controlo cont++; } // inserir a linha criada tabela.addView(linha1); } // resto if (nAlunos % 4 != 0) { TableRow linha1 = new TableRow(getBaseContext()); linha1.setLayoutParams(linha.getLayoutParams()); for (int j = 0; j < nAlunos % 4; j++) { // ********************************** // Nome, id e foto do aluno final String alumni = nomeAluno[cont]; final int idAL = idAluno[cont]; final String alunFot = fotoAluno[cont]; // *********************************** // novo bot�o Button bt1 = new Button(bt.getContext()); // copiar os parametros do bot�o original bt1.setLayoutParams(bt.getLayoutParams()); // se o aluno tiver foto, vou busca-la if (fotoAluno[cont] != null) { String imageInSD = Environment.getExternalStorageDirectory().getAbsolutePath() + "/School-Data/Students/" + fotoAluno[cont]; Bitmap bitmap = BitmapFactory.decodeFile(imageInSD); ImageView imageView = new ImageView(this); // ajustar o tamanho da imagem imageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 240, 240, false)); // enviar para o bot�o bt1.setCompoundDrawablesWithIntrinsicBounds(null, imageView.getDrawable(), null, null); } else { // sen�o copia a imagem do bot�o original bt1.setCompoundDrawables(null, bt.getCompoundDrawablesRelative()[1], null, null); } // addicionar o nome bt1.setText(nomeAluno[cont]); // Defenir o que faz o bot�o ao clicar bt1.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { // Entrar na activity Bundle wrap = new Bundle(); wrap.putString("Escola", Escola); wrap.putInt("Escola_ID", idEscola); wrap.putString("Professor", Professor); wrap.putInt("Professor_ID", idProfessor); wrap.putString("Foto_professor", FotoProf); wrap.putString("Turma", Turma); wrap.putInt("Turma_ID", idTurma); wrap.putString("Aluno", alumni); wrap.putInt("Aluno_ID", idAL); wrap.putString("Foto_Aluno", alunFot); Intent it = new Intent(getApplicationContext(), EscModo.class); it.putExtras(wrap); startActivity(it); } }); // inserir o bot�o na linha linha1.addView(bt1); // incrementar o contador de controlo cont++; } // inserir a linha criada tabela.addView(linha1); } // por fim escondo a 1� linha tabela.removeView(linha); }