Mam w moim fragmencie metodę sendData()
. Ta metoda rozpoczyna nową aktywność. Chcę nazwać tę metodę z mojego ArrayAdapter
.Wywołanie metody fragmentacji z adaptera
Oto mój kod: -
HomeFragment.java
stagAdaper = new StaggeredAdapter(myContext, android.R.layout.simple_list_item_1, getList);
mGridView.setAdapter(stagAdaper);
private void sendData(int position)
{
myDialog = new ProgressDialog(myContext).show(getActivity(), "Fetching news..", "Just a moment");
myDialog.getWindow().setContentView(R.layout.openarticlewaitprogress);
myDialog.getWindow().setTitle("Loading..");
myDialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
new NewsDetails(myDialog);
Intent nIntent = new Intent(getActivity(),Details.class);
String Body=getList.get(position).getBody();
newsIntent.putExtra("Body", Body);
startActivity(nIntent);
}
StaggeredAdapter.java
viewHolder.layGridLayout.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
//viewHolder.layGridLayout.setForeground(R.drawable.foreground_selector);
}
});
return convertView;
}
Jak mogę to zrobić?
wyglądać to i nauczyć się komunikować Fragments: http://stackoverflow.com/questions/24081101/using-localbroadcastmanager-to-communicate-from-fragment-to-activity/24083101#24083101 –