/** * On button click, the check dialog will be brought up. * * @param button */ public Check(Button button) { Activity activity = (Activity) button.getContext(); // inflate the dialog view from the resource and create the dialog with // that view AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle("Check"); LayoutInflater inflater = activity.getLayoutInflater(); View v = inflater.inflate(R.layout.check_dialog, null); builder.setView(v); builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // no special action when user clicks ok } }); this.dialog = builder.create(); // get references to the dynamic controls in the view this.checkTest = (TextView) v.findViewById(R.id.check_test); this.checkTargetProgress = (ProgressBar) v.findViewById(R.id.check_target_progress); this.checkActualProgress = (ProgressBar) v.findViewById(R.id.check_actual_progress); this.checkResult = (TextView) v.findViewById(R.id.check_result); this.maxRoll = button.getResources().getInteger(R.integer.max_roll); this.wrapper = new Wrapper(); button.setOnClickListener(wrapper); }
@Override protected void onPostExecute(List<Line> listLine) { // TODO Auto-generated method stub if (listLine == null || listLine.isEmpty()) Toast.makeText(btnLine.getContext(), R.string.message_bus_query_failed, Toast.LENGTH_SHORT) .show(); else { this.busLineAdapter.getDataSource().clear(); this.busLineAdapter.getDataSource().addAll(listLine); this.busLineAdapter.initPageConfig(); this.busLineAdapter.notifyDataSetChanged(); } // 隐藏进度条 waiFrame.setVisibility(FrameLayout.GONE); // 启用搜索按钮 btnLine.setEnabled(true); // 启用列表 lineListView.setEnabled(true); }
/** * 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); }