onActivityResult:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode==202){
//Next
msg=msg_id1[++msg_cureentposition];
Intent i=new Intent(details.this,details1.class);
Bundle bundle = new Bundle();
if(msg_cureentposition==msg_length-1)
bundle.putBoolean("nextFlag",false);
else
bundle.putBoolean("nextFlag",true);
if(msg_cureentposition==0)
bundle.putBoolean("previousFlag",false);
else
bundle.putBoolean("previousFlag",true);
bundle.putString("ID",msg);
i.putExtras(bundle);
startActivityForResult(i,100);
}else if(resultCode==201){
//Previous
msg=msg_id1[--msg_cureentposition];
Intent i=new Intent(details.this,details1.class);
Bundle bundle = new Bundle();
if(msg_cureentposition==msg_length-1)
bundle.putBoolean("nextFlag",false);
else
bundle.putBoolean("nextFlag",true);
if(msg_cureentposition==0)
bundle.putBoolean("previousFlag",false);
else
bundle.putBoolean("previousFlag",true);
bundle.putString("ID",msg);
i.putExtras(bundle);
startActivityForResult(i,100);
}
}
LIstCiew onClickListner:
msg_length=msg_id1.length;
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView arg0, View arg1,
int pos, long arg3) {
// TODO Auto-generated method stub
Intent i=new Intent(details.this,details1.class);
msg_cureentposition=pos;
Bundle bundle = new Bundle();
if(msg_cureentposition==msg_length-1)
bundle.putBoolean("nextFlag",false);
else
bundle.putBoolean("nextFlag",true);
if(msg_cureentposition==0)
bundle.putBoolean("previousFlag",false);
else
bundle.putBoolean("previousFlag",true);
bundle.putString("ID",msg_id1[pos]);
i.putExtras(bundle);
startActivityForResult(i,100);
}
});
Prev ANd Next Button:
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(next_flag)
{
previous.setVisibility(View.VISIBLE);
setResult(202);
finish();
}else{
next.setVisibility(View.INVISIBLE);
Toast.makeText(getApplicationContext(), "Last News", Toast.LENGTH_SHORT).show();
}
}
});
previous.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if( pre_flag)
{
next.setVisibility(View.VISIBLE);
setResult(201);
finish();
}else{
previous.setVisibility(View.INVISIBLE);
Toast.makeText(getApplicationContext(), "First News", Toast.LENGTH_SHORT).show();
}
}
});
No comments:
Post a Comment