Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- NOTAS:
- -Ignorei os imports... nao vou tar a decorar aquela merda toda...
- -Nao sei até que ponto é isto que é para fazer, mas eu faria assim
- -Assumi muita merda que nao sei se era para assumir ou nao... Por exemplo o gestor de base de dados
- -Pouco me interessa o XML do layout, se for preciso eu posso fazer mas mais de metade do pessoal nao o vai conseguir fazer num teste... Mas pronto... fuck it...
- */
- //Parte II
- //1
- public class P1 extends Activity
- {
- EditText TipoMoeda;
- EditText TipoMoedaConv;
- EditText FactorConv;
- EditText Valor;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- TipoMoeda = (EditText)findViewById(R.id.tipomoeda); //textview para o tipo de moeda a converter
- TipoMoedaConv = (EditText)findViewById(R.id.tipomoedaconv); //textview para o tipo de moeda convertida
- FactorConv = (EditText)findViewById(R.id.factorconv); //textview para o factor de conversao
- Valor = (EditText)findViewById(R.id.valor); //textview com o valor a converter
- }
- //Função para o click do butão "Converter"
- public void Converter(View v)
- {
- float vl = Float.parseFloat(Valor.getText().toString());
- float tot = vl * Float.parseFloat(FactorConv.getText().toString());
- Toast.makeText(getApplicationContext(), vl + " " + TipoMoeda.getText() + " representam " + tot + " " + TipoMoedaConv.getText(),Toast.LENGTH_LONG).show();
- }
- }
- //2
- public class P2 extends Activity
- {
- private EditText Email;
- private EditText Name;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_p2);
- Email = (EditText) findViewById(R.id.email);
- Name = (EditText) findViewById(R.id.nome);
- }
- //função para o click do botao Adicionar Contacto
- public void AddContacto(View v)
- {
- Intent intent = new Intent();
- intent.putExtra(ContactsContract.Intents.Insert.EMAIL, Email.getText())
- .putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE, ContactsContract.CommonDataKinds.Email.TYPE_WORK)
- .putExtra(ContactsContract.Intents.Insert.NAME, Name.getText())
- startActivity(intent);
- }
- }
- //3
- public class P3 extends ActionBarActivity
- {
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_p3);
- }
- //public para o click no enviar email
- public void SendEmail(View v)
- {
- Intent email = new Intent(Intent.ACTION_SEND);
- email.setData(Uri.parse("mailto:"));
- email.setType("text/plain");
- email.putExtra(Intent.EXTRA_EMAIL, "pantonio@xx.pt");
- email.putExtra(Intent.EXTRA_SUBJECT, "Reserva efectuada");
- email.putExtra(Intent.EXTRA_TEXT, "A sua reserva foi feita com sucesso. Informamos que a sua reserva tem o código 12345");
- try
- {
- startActivity(Intent.createChooser(email, "Send mail..."));
- finish();
- }
- catch(Exception e)
- {
- Toast.makeText(getApplicationContext(), "" + e.getMessage(), Toast.LENGTH_LONG).show();
- }
- }
- }
- //4
- public class P4 extends ActionBarActivity
- {
- Spinner sp;
- ArrayList<String> al;
- GestorBaseDados bd;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_p4);
- bd = new GestorBaseDados(getApplicationContext());
- al = new ArrayList<>();
- Cursor c = bd.GetDadosTabela("Spinner");
- if (c.moveToFirst())
- {
- do
- {
- al.add(c.getString(c.getColumn("Texto")));
- }while (c.moveToNext());
- }
- sp = (Spinner)findViewById(R.id.spinner);
- ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(),android.R.layout.simple_spinner_item,al);
- sp.setAdapter(adapter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement