Open new screen with clicked user options

Asked

Viewed 50 times

3

I have a listview and in it I put all the users of the bank, I use a adapterView to get the position and the id, but I do not know how I will open a new screen for the advanced options for each user.

follows the code

protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
      .permitAll().build();
    StrictMode.setThreadPolicy(policy);
      setContentView(R.layout.list);
      listView = (ListView) findViewById(R.id.listView1);
      accessWebService();

      listView.setOnItemClickListener(new OnItemClickListener() {
             public void onItemClick(AdapterView<?> parent, View view,
                 int position, long id) {
               // When clicked, show a toast with the TextView text
               Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
                   Toast.LENGTH_SHORT).show();
             }
           });

     }

You would have to link some identifier attribute in the item to pick it up, or I can do everything with Json?

  • Is he in a local bank? Or comes from a webservice?

  • comes from a webservice on apache

  • So, I think you will have to pass this user ID to and there (through another request) pick up the server data through the ID.

1 answer

2


listDebitosPendentes.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                  Intent intent = new Intent(getApplicationContext(), DetalhesDebitosActivity.class);

                  //Passa para a activity o id no banco de dados
                  intent.putExtra("ID", id);

                  startActivity(intent);
        }

    });

In the other Activity You take it this way.

 Long idSelected = getIntent().getLongExtra("ID", 0);

In my case I do a query picking by this ID.

int id = Integer.valueOf(idSelected.toString());

debitosPendentes = debitoPendentesDao.queryForId(id);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.