int i=0;
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (i < List.size() - 1) {
i = i + 1;
//some tasks
}
if (i == List.size() - 1)
Toast.makeText(MainActivity.this, "This is the last article", Toast.LENGTH_LONG).show();
}
});
prev.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (i > 0) {
i = i - 1;
//some tasks
}
if (i == 0)
Toast.makeText(MainActivity.this, "This is the First article", Toast.LENGTH_LONG).show();
}
});
int i=0;
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (i == List.size() - 1)
i = -1;
i = i + 1;
if (i < List.size() && i > -1) {
//some tasks
}
}
});
prev.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (i == 0)
i = List.size();
i = i - 1;
if (i < List.size() && i > -1) {
//some tasks
}
}
});