Open new screen with clicked user options

3

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

follow 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();
             }
           });

     }

Would you have to link some identifier attribute in the item to get it, or can I do everything with Json?

    
asked by anonymous 16.12.2016 / 19:40

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 get as follows.

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

In my case I make a query by taking this ID.

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

debitosPendentes = debitoPendentesDao.queryForId(id);
    
16.12.2016 / 20:33