Tecnologia do Blogger.
RSS

[androidbrasil-dev] putExtras entre SherlockListActivity e Fragments

Galera tenho uma activity com uma lista, ai quando vou clicar na lista quero passar oque esta escrito nela
paraum textview que esta em  uma activity fragment.

só que não estou conseguindo.

procurei no livro de android para tablets mais não achei

Segue as classes:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        carregaMes();

        getFragmentManager().beginTransaction().replace(R.id.botoes_fragments, new LogoInicio()).commit();

        listView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View selectedItemView,
                    int posicao, long id) {
                // TODO Auto-generated method stub
               
                // aqui chama a fragment com os botoes e o text view.
                Botoes dpf = new Botoes();
                android.app.FragmentTransaction beginTransaction = getFragmentManager().beginTransaction();
                beginTransaction.replace(R.id.botoes_fragments, dpf, Botoes.class.getCanonicalName());
                beginTransaction.addToBackStack("botoes_fragments");
                beginTransaction.commit();
               
                //passo oque foi clicado por putextra, para ser preenchido no textview dos botoes
                Intent prox = new Intent(getApplicationContext(), Botoes.class);
                prox.putExtra("NOMES", ((TextView) selectedItemView).getText());
                startActivity(prox);
               
                 }

        });

    }// aqui fecha o oncreate

______________________

public class Botoes extends Fragment {
    private TextView mesclick;
    private String textlistview = null;

        //recebedo putextras o valor do text view
        textlistview = getActivity().getIntent().getStringExtra("NOMES");
        this.mesclick = (TextView) botoes.findViewById(R.id.textViewMesClicado);
        this.mesclick.setText("textlistview");

--
 
 

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário