我有两个活动A和B。
在 A 活动中,我正在显示listview
. 当用户单击 Activity A 上列出的任何项目时,它应该重定向到下一个 Activity B,并且它应该显示该特定的单个项目以及 Next/Previous 按钮。
当用户单击“下一个”或“上一个”按钮时,该项目应相应更改。
我应该使用listview
还是简单地使用 textview 来显示活动 B 上的特定记录,这些记录会更改上一个/下一个的单击。如何做到这一点?
请帮帮我。这是我的活动 A
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_giga);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
System.out.println("My Exception 333: ");
loadNews();
}
private void loadNews(){
try{
BaseFeedParserGiga parser = new BaseFeedParserGiga();
messages = parser.parsse();
final String title[]= new String[messages.size()] ;
final String pubdate[]= new String[messages.size()] ;
final String link[]= new String[messages.size()] ;
final String Long[]= new String[messages.size()] ;
final String image[]= new String[messages.size()] ;
list = new ArrayList<String>(messages.size());
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for (com.example.newsworld.MessageGiga msg : messages){
list.add(msg.getTitle());
title[j]=msg.getTitle();
pubdate[i]=msg.getPubdate();
link[m]=msg.getLink();
Long[l]=msg.getDesc();
Document doc = Jsoup.parse(Long[l]);
Elements links = doc.getElementsByTag("img");
String src = links.attr("src");
image[k]=src;
setListAdapter(new ArrayAdapter<String>(GigaActivity.this, R.layout.rows, list ){
@Override
public View getView(final int j, View convertView, ViewGroup parent) {
View row;
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.row, parent, false);
System.out.println("My Exception 5: ");
holder = new ViewHolder();
holder.txtclick= (TextView) convertView.findViewById(R.id.textView1);
holder.txtTitle = (TextView) convertView.findViewById(R.id.textView2);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
String s=image[j];
holder.txtTitle.setText(title[j]+"\n\n"+pubdate[j]);
holder.txtclick.setOnClickListener( new OnClickListener()
{
public void onClick(View viewParam)
{
Intent in = new Intent(GigaActivity.this,GigaPage.class);
in.putExtra("title", title[j]);
in.putExtra("pubdate", pubdate[j]);
in.putExtra("link", link[j]);
startActivity(in);
overridePendingTransition(R.anim.grow_from_middle,R.anim.shrink_to_middle);
}
});
return convertView;
}
class ViewHolder {
TextView txtLat;
TextView txtTitle;
TextView txtPubdate;
ImageView txtLink;
TextView txtclick;
}
});
j++;
i++;
m++;
l++;
k++;
}
}catch(Exception exc){
System.out.println("My Exception : "+exc.getMessage());
}
}