从适配器调用片段方法
2022-08-31 22:16:30
我的片段中有一种方法。此方法启动一个新的活动。我想从我的.sendData()
ArrayAdapter
这是我的代码:-
家庭碎屑.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);
}
交错adapter.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;
}
我该怎么做?