I have a list of items of object. I am creating dynamic buttons as per the size of a list using for loop.
I am showing some data when its the first item of the loop. Now /i want to switch the data when I will click the buttons.
Buttons will have the numbers of the item, if three items are present in the list , three buttons are there named one, two, three.
So if I click on first I want to show data of first item, if second clicked data of second item respectively.
I tried to do it, but I am not able to get the result.
#Override
public void doPostExecute(List<Payment> list1)
{
list.addAll(list1);
for(final Payment payment : list) {
i++;
Button myButton = new Button(getActivity());
LinearLayoutCompat.LayoutParams lp = new LinearLayoutCompat.LayoutParams(60,30);
linear_buttons.addView(myButton, lp);
myButton.setText(String.valueOf(i));
myButton.setBackgroundResource(R.drawable.edit_button);
myButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (payment.getPaidAmount() != null && !payment.getPaidAmount().equals("null"))
txt_paid.setText("$" + payment.getPaidAmount());
if (payment.getProductStatus() != null && !payment.getProductStatus().equals("null")) {
if (payment.getProductStatus().equals("1")) {
txt_status.setText(getString(R.string.paid));
button_complain.setVisibility(View.VISIBLE);
button_more.setVisibility(View.GONE);
} else if (payment.getProductStatus().equals("0")) {
txt_status.setText(getString(R.string.unPaid));
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.GONE);
} else if (payment.getProductStatus().equals("5")) {
txt_status.setText(getString(R.string.processing));
button_complain.setVisibility(View.VISIBLE);
button_more.setVisibility(View.GONE);
} else if (payment.getProductStatus().equals("6")) {
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.VISIBLE);
txt_status.setText(getString(R.string.releasedStatus));
} else if (payment.getProductStatus().equals("8")) {
txt_status.setText(getString(R.string.disputeStatus));
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.VISIBLE);
} else if (payment.getProductStatus().equals("9")) {
txt_status.setText(getString(R.string.disputeResolvedStatus));
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.VISIBLE);
} else if (payment.getProductStatus().equals("2")) {
txt_status.setText(getString(R.string.completedStatus));
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.VISIBLE);
}
if (payment.getTpAmount() != null && !payment.getTpAmount().equals("null")) {
String amount = String.format(Locale.US, "%.2f", Double.parseDouble(payment.getTpAmount()));
txt_tp_amount.setText("$" + amount);
}
if (payment.getCommission() != null && !payment.getCommission().equals("null")) {
String amount = String.format(Locale.US, "%.2f", Double.parseDouble(payment.getCommission()));
txt_comission.setText("$" + amount);
}
if (payment.getTax() != null && !payment.getTax().equals("null")) {
String amount = String.format(Locale.US, "%.2f", Double.parseDouble(payment.getTax()));
txt_tax.setText("$" + amount);
}
if (payment.getPayeEmail() != null && !payment.getPayeEmail().equals("null")) {
txt_payee_email.setText(payment.getPayeEmail());
}
if (payment.getPayerEmail() != null && !payment.getPayerEmail().equals("null")) {
txt_payer_email.setText(payment.getPayerEmail());
}
if (payment.getPayerName() != null && !payment.getPayerName().equals("null")) {
txt_payer_name.setText(payment.getPayerName());
}
if (payment.getVendorId() != null && !payment.getVendorId().equals("null")) {
txt_vendor_id.setText(payment.getVendorId());
}
}
}
});
if(i==1) {
if (payment.getPaidAmount() != null && !payment.getPaidAmount().equals("null"))
txt_paid.setText("$" + payment.getPaidAmount());
if (payment.getProductStatus() != null && !payment.getProductStatus().equals("null")) {
if (payment.getProductStatus().equals("1")) {
txt_status.setText(getString(R.string.paid));
button_complain.setVisibility(View.VISIBLE);
button_more.setVisibility(View.GONE);
} else if (payment.getProductStatus().equals("0")) {
txt_status.setText(getString(R.string.unPaid));
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.GONE);
} else if (payment.getProductStatus().equals("5")) {
txt_status.setText(getString(R.string.processing));
button_complain.setVisibility(View.VISIBLE);
button_more.setVisibility(View.GONE);
} else if (payment.getProductStatus().equals("6")) {
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.VISIBLE);
txt_status.setText(getString(R.string.releasedStatus));
} else if (payment.getProductStatus().equals("8")) {
txt_status.setText(getString(R.string.disputeStatus));
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.VISIBLE);
} else if (payment.getProductStatus().equals("9")) {
txt_status.setText(getString(R.string.disputeResolvedStatus));
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.VISIBLE);
} else if (payment.getProductStatus().equals("2")) {
txt_status.setText(getString(R.string.completedStatus));
button_complain.setVisibility(View.GONE);
button_more.setVisibility(View.VISIBLE);
}
if (payment.getTpAmount() != null && !payment.getTpAmount().equals("null")) {
String amount = String.format(Locale.US, "%.2f", Double.parseDouble(payment.getTpAmount()));
txt_tp_amount.setText("$" + amount);
}
if (payment.getCommission() != null && !payment.getCommission().equals("null")) {
String amount = String.format(Locale.US, "%.2f", Double.parseDouble(payment.getCommission()));
txt_comission.setText("$" + amount);
}
if (payment.getTax() != null && !payment.getTax().equals("null")) {
String amount = String.format(Locale.US, "%.2f", Double.parseDouble(payment.getTax()));
txt_tax.setText("$" + amount);
}
if (payment.getPayeEmail() != null && !payment.getPayeEmail().equals("null")) {
txt_payee_email.setText(payment.getPayeEmail());
}
if (payment.getPayerEmail() != null && !payment.getPayerEmail().equals("null")) {
txt_payer_email.setText(payment.getPayerEmail());
}
if (payment.getPayerName() != null && !payment.getPayerName().equals("null")) {
txt_payer_name.setText(payment.getPayerName());
}
if (payment.getVendorId() != null && !payment.getVendorId().equals("null")) {
txt_vendor_id.setText(payment.getVendorId());
}
}
}
}
}
How can I achieve this? please help.. Thank you.
You can set an onClickLister to the button in that row which will have a reference to that row's data. Use an intent to start the detailed activity and add the clicked item's data as an extra.
#Override
public View getView(int position, View convertView, ViewGroup parent) {
//Inflate your row
button.setOnClickListener(new OnClickListener(){
#Override
//On click function
public void onClick(View view) {
HashMap<String, String> item = contactsList.get(position);
//Create the intent to start another activity
Intent intent = new Intent(view.getContext(), DetailActivity.class);
intent.putExtra("data", item);
view.getContext().startActivity(intent);
}
});
});
in the receiving activity, you can get the data from the intent
HashMap<String, String> data = getIntent().getExtras().getParcelableExtra("data");
You are using the variable i as a global variable and using i++ inside the loop. So inside the onClick method the if(i == 1) is either always false, or always true.
Make variable local and use myButton.setId(i); inside your for loop where you create buttons.
Now inside OnClickListener you can use int id = v.getId(); and use if(id == 1)
Related
Here is my code below:
tvWatch.setOnClickListener(v -> {
earnCreditDialog.dismiss();
RewardedAd rewardedAd = adMobUtils().getRewardedAd();
if (rewardedAd != null /*&& rewardedAd.isLoaded()*/) {
isEarnCredit = true;
rewardedAd.show(TournamentActivity.this, rewardedAdCallback);
rewardedAd.setFullScreenContentCallback(setFullScreenContentCallback);
} else {
CommonUtils.showMessage(TournamentActivity.this, getString(R.string.earn_credit_not_available));
if (rewardedAd == null) {
Timber.e("Create New Rewarded Ad");
loadRewardVideoAd(true);
} else {
Timber.e("Loading Current Rewarded Ad");
}
}
});
I would also like to add a dialog that I have coded already before the rewarded ad is shown. Here is the code below:
public void showAdsLoadingProgressDialog() {
if (adsLoadingDialog == null || !adsLoadingDialog.isShowing()) {
adsLoadingDialog = new Dialog(BaseActivity.this);
Window window = adsLoadingDialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
}
adsLoadingDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
adsLoadingDialog.setContentView(R.layout.custom_ads_loading_dialog_layout);
adsLoadingDialog.show();
adsLoadingDialog.setCancelable(false);
adsLoadingDialog.setCanceledOnTouchOutside(false);
}
}
I'm having trouble removing the "parent channel shortcut" even though I already have it hidden (view2.setvisiblity(view.GONE)). I'm using gridview android:numColumns="3".The list user display starts from the left side, If I want to remove it, how do I do that?
#Override
public int getCount() {
int count = currentusers.size() + subchannels.size() + stickychannels.size();
if ((curchannel != null) && (curchannel.nParentID > 0)) {
count++; // include parent channel shortcut
}
return count;
}
#Override
public Object getItem(int position) {
if (position < stickychannels.size()) {
return stickychannels.get(position);
}
// sticky channels are first so subtract these
position -= stickychannels.size();
if (position < currentusers.size()) {
return currentusers.get(position);
}
// users are first so subtract these
position -= currentusers.size();
if ((curchannel != null) && (curchannel.nParentID > 0)) {
if(position == 0) {
Channel parent = ttservice.getChannels().get(curchannel.nParentID);
if(parent != null)
return parent;
return new Channel();
}
position--; // subtract parent channel shortcut
}
return subchannels.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public int getItemViewType(int position) {
if (position < stickychannels.size())
return INFO_VIEW_TYPE;
// sticky channels are first so subtract these
position -= stickychannels.size();
if (position < currentusers.size())
return USER_VIEW_TYPE;
// users are first so subtract these
position -= currentusers.size();
if ((curchannel != null) && (curchannel.nParentID > 0)) {
if (position == 0) {
return PARENT_CHANNEL_VIEW_TYPE;
}
position--; // subtract parent channel shortcut
}
return CHANNEL_VIEW_TYPE;
}
#Override
public int getViewTypeCount() {
return VIEW_TYPE_COUNT;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
Object item = getItem(position);
if(item instanceof Channel) {
final Channel channel = (Channel) item;
switch (getItemViewType(position)) {
case PARENT_CHANNEL_VIEW_TYPE :
// show parent channel shortcut
if (convertView == null ||
convertView.findViewById(R.id.parentname) == null)
convertView = inflater.inflate(R.layout.item_channel_back, parent, false);
convertView.setVisibility(view.GONE)
break;
case CHANNEL_VIEW_TYPE :
if (convertView == null ||
convertView.findViewById(R.id.channelname) == null)
convertView = inflater.inflate(R.layout.item_channel, parent, false);
ImageView chanicon = convertView.findViewById(R.id.channelicon);
TextView name = convertView.findViewById(R.id.channelname);
TextView topic = convertView.findViewById(R.id.chantopic);
Button join = convertView.findViewById(R.id.join_btn);
int icon_resource = R.drawable.channel_orange;
if(channel.bPassword) {
icon_resource = R.drawable.channel_pink;
chanicon.setContentDescription(getString(R.string.text_passwdprot));
chanicon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
else {
chanicon.setContentDescription(null);
chanicon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
chanicon.setImageResource(icon_resource);
if(channel.nParentID == 0) {
// show server name as channel name for root channel
ServerProperties srvprop = new ServerProperties();
ttclient.getServerProperties(srvprop);
name.setText(srvprop.szServerName);
}
else {
name.setText(channel.szName);
}
topic.setText(channel.szTopic);
OnClickListener listener = v -> {
if (v.getId() == R.id.join_btn) {
joinChannel(channel);
}
};
join.setOnClickListener(listener);
join.setAccessibilityDelegate(accessibilityAssistant);
join.setEnabled(channel.nChannelID != ttclient.getMyChannelID());
if (channel.nMaxUsers > 0) {
int population = Utils.getUsers(channel.nChannelID, ttservice.getUsers()).size();
((TextView)convertView.findViewById(R.id.population)).setText((population > 0) ? String.format("(%d)", population) : "");
}
break;
case INFO_VIEW_TYPE :
if (convertView == null ||
convertView.findViewById(R.id.titletext) == null)
convertView = inflater.inflate(R.layout.item_info, parent, false);
TextView title = convertView.findViewById(R.id.titletext);
TextView details = convertView.findViewById(R.id.infodetails);
title.setText(channel.szName);
details.setText(channel.szTopic);
break;
}
}
else if(item instanceof User) {
if (convertView == null ||
convertView.findViewById(R.id.nickname) == null)
convertView = inflater.inflate(R.layout.item_user, parent, false);
ImageView usericon = convertView.findViewById(R.id.usericon);
TextView nickname = convertView.findViewById(R.id.nickname);
TextView status = convertView.findViewById(R.id.status);
final User user = (User) item;
String name = Utils.getDisplayName(getBaseContext(), user);
nickname.setText(name);
status.setText(user.szStatusMsg);
boolean talking = (user.uUserState & UserState.USERSTATE_VOICE) != 0;
boolean female = (user.nStatusMode & TeamTalkConstants.STATUSMODE_FEMALE) != 0;
boolean away = (user.nStatusMode & TeamTalkConstants.STATUSMODE_AWAY) != 0;
int icon_resource;
if(user.nUserID == ttservice.getTTInstance().getMyUserID()) {
talking = ttservice.isVoiceTransmitting();
}
if(talking) {
if(female) {
icon_resource = R.drawable.woman_green;
nickname.setContentDescription(getString(R.string.user_state_now_speaking, name) + " 👩");
}
else {
icon_resource = R.drawable.man_green;
nickname.setContentDescription(getString(R.string.user_state_now_speaking, name) + " 👨");
}
}
else {
if(female) {
icon_resource = away? R.drawable.woman_orange : R.drawable.woman_blue;
nickname.setContentDescription(name + " 👩");
}
else {
icon_resource = away? R.drawable.man_orange : R.drawable.man_blue;
nickname.setContentDescription(name + " 👨");
}
}
status.setContentDescription(away ? getString(R.string.user_state_away) : null);
usericon.setImageResource(icon_resource);
usericon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
Button sndmsg = convertView.findViewById(R.id.msg_btn);
OnClickListener listener = v -> {
if (v.getId() == R.id.msg_btn) {
Intent intent = new Intent(MainActivity.this, TextMessageActivity.class);
startActivity(intent.putExtra(TextMessageActivity.EXTRA_USERID, user.nUserID));
}
};
sndmsg.setOnClickListener(listener);
sndmsg.setAccessibilityDelegate(accessibilityAssistant);
}
convertView.setAccessibilityDelegate(accessibilityAssistant);
return convertView;
}
The list user display starts from the left side
My Array will not add anything to the list after the first and keeps returning null when i search for anything after.
Is there something wrong with this method?
public void addItem(Item newItem) throws DuplicateItemException {
Item tempItem;
if(itemList == null)
itemList.add(newItem);
try {
tempItem = findItem(newItem.ID);
if(tempItem == null) {
itemList.add(newItem);
}
else {
throw new DuplicateItemException(newItem.ID + "already exists");
}
}
catch (ItemNotFoundException e) {
itemList.add(newItem);
}
}
In your code:
if(itemList == null)
itemList.add(newItem);
if itemList is indeed null, how can you add to it?
Use this instead
if(itemList == null) {
itemList = new ArrayList<>();
itemList.add(newItem);
}
I develop a android app here hava a accessabilty service for read window text from ussd dial.
I am success for do it and it working nice. But when screen light turn off and get locked The accessAbiltyService not working.
I provide my coding here of access ability service
please see and give me suggestion how I solve it that it working for screen on/off.
public class USSDService extends AccessibilityService {
public static String TAG = USSDService.class.getSimpleName();
#Override
public void onAccessibilityEvent(AccessibilityEvent event) {
AccessibilityNodeInfo source = event.getSource();
/* if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && !event.getClassName().equals("android.app.AlertDialog")) { // android.app.AlertDialog is the standard but not for all phones */
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && !String.valueOf(event.getClassName()).contains("AlertDialog")) {
return;
}
if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED && (source == null || !source.getClassName().equals("android.widget.TextView"))) {
return;
}
if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED && TextUtils.isEmpty(source.getText())) {
return;
}
List<CharSequence> eventText;
if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
eventText = event.getText();
} else {
eventText = Collections.singletonList(source.getText());
}
String text = processUSSDText(eventText);
if( TextUtils.isEmpty(text) ) return;
// Close dialog
performGlobalAction(GLOBAL_ACTION_BACK); // This works on 4.1+ only
if (source != null) {
//capture the EditText simply by using FOCUS_INPUT (since the EditText has the focus), you can probably find it with the viewId input_field
AccessibilityNodeInfo inputNode = source.findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
if (inputNode != null) {//prepare you text then fill it using ACTION_SET_TEXT
//saff 1
if (text.indexOf("Default") >= 0) {
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,"0");
inputNode.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
//"Click" the Send button
List<AccessibilityNodeInfo> list = source.findAccessibilityNodeInfosByText("Send");
for (AccessibilityNodeInfo node : list) {
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
//staf 2
if (text.indexOf("topUp") >= 0) {
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,"1");
inputNode.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
//"Click" the Send button
List<AccessibilityNodeInfo> list = source.findAccessibilityNodeInfosByText("Send");
for (AccessibilityNodeInfo node : list) {
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
}
}
Log.d(TAG, text);
// Handle USSD response here
}
private String processUSSDText(List<CharSequence> eventText) {
for (CharSequence s : eventText) {
String text = String.valueOf(s);
// Return text if text is the expected ussd response
if( true ) {
return text;
}
}
return null;
}
#Override
public void onInterrupt() {
}
#Override
protected void onServiceConnected() {
super.onServiceConnected();
Log.d(TAG, "onServiceConnected");
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
info.flags = AccessibilityServiceInfo.DEFAULT;
info.packageNames = new String[]{"com.android.phone"};
info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
setServiceInfo(info);
}
}
Thanks
For help
I am working on an application in which have two navigation button namely 'previous and next' which on tap load stories respectively. When i tap these buttons gently they work fine button when i tap next button to the last index continuously without any break then the previous button does not work or similarly when i start tapping previous button to the very first index i am unable to move forward.
Remember this only happens at the extreme cases, onClick is not called, don't know why.
My code is as follows, please help me out. Thanks in advance.
this the code of onClick, which works fine in all cases except the extreme cases, when buttons are not tapped gently.
public void onClick(View v) {
if (visible == true) {
Log.e("visible", "true");
return;
}
visible = true;
try {
Log.e("Now", "On Click");
pDialog = new ProgressDialog(StoriesListController.this);
pDialog.setIndeterminate(true);
pDialog.setIcon(R.drawable.icon_small);
pDialog.setCancelable(true);
if (isFavoriteList == true) {
pDialog.setMessage("Loading favorites...");
} else {
pDialog.setMessage("Loading data...");
}
pDialog.setTitle("Please wait");
pDialog.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface arg0) {
if (cancelableHeavyWorker != null) {
cancelableHeavyWorker.setHandler(null);
}
finish();
}
});
pDialog.show();
if (v == next) {
if (ind < items.size() - 1) {
ind++;
loadAndShowNextActivity();
}
} else if (v == previous) {
if (ind > 0) {
ind--;
loadAndShowNextActivity();
}
}
// realeaseMemoryIfneededofStory(ind);
} catch (Exception e) {
Log.e("Error", "--.OnClink Message" + e.toString());
e.printStackTrace();
}
}
Moreover, the boolean variable "visible" is being set to false in the callback function.
The Code of Call Back Function is as follows:
private void fetchTopStoryDetailCallback(Object resultVector) {
System.out.println("fetchTopStoryDetailCallback");
try {
Vector<?> v = (Vector<?>) resultVector;
boolean completedOrFailed = ((Boolean) v.elementAt(0)).booleanValue();
if (completedOrFailed == true) {
boolean slideshow = ((Boolean) v.elementAt(1)).booleanValue();
Object result = v.elementAt(2);
String res[] = (String[]) result;
if (slideshow) {
if (Utils.topStorySlidesArrayList != null && Utils.topStorySlidesArrayList.size() > 0) {
Intent articleActivityIntent = new Intent(this, SlideShowActivity.class);
articleActivityIntent.putExtra("storyData", (String[]) result);
articleActivityIntent.putExtra("back", back);
articleActivityIntent.putStringArrayListExtra("sid", slideids);
// articleActivityIntent.putExtra("contentType", )
articleActivityIntent.putExtra("addkey", ADDS_KEY);
showActivityInContoller(articleActivityIntent);
hidePrgressgingDailog();
} else {
hidePrgressgingDailog();
this.closeActivity = true;
showMessage("Error", "This story encounter an error while opening. Check your Internet Connection and try later");
}
} else {
if (res[3] != null && (!(res[3].equalsIgnoreCase("null")) && (!res[3].equals("")))) {
Intent slideshowActivtyIntent = new Intent(this, ArticleActivity.class);
slideshowActivtyIntent.putExtra("storyData", (String[]) result);
slideshowActivtyIntent.putExtra("back", back);
slideshowActivtyIntent.putExtra("addkey", ADDS_KEY);
showActivityInContoller(slideshowActivtyIntent);
hidePrgressgingDailog();
} else {
hidePrgressgingDailog();
this.closeActivity = true;
showMessage("Error", "This story encounter an error while opening. Check your Internet Connection and try later");
}
}
} else {
showMessage("Error", "This story encounter an error while opening. Check your Internet Connection and try later");
hidePrgressgingDailog();
}
} catch (Exception e) {
Log.e("StoriesController", "Message = " + e.toString());
e.printStackTrace();
}
finally {visible = false; }
}
this is how visiblity of the buttons is set...!!!!
private void adjustButtonsVisibility() {
try {
if (items.size() == 1) {
next.setEnabled(false);
next.setImageResource(R.drawable.navigator_next_disable);
previous.setEnabled(false);
previous.setImageResource(R.drawable.navigator_previous_disable);
//hidePrgressgingDailog();
return;
}
if (ind == 0) {
previous.setEnabled(false);
next.setEnabled(true);
previous.setImageResource(R.drawable.navigator_previous_disable);
next.setImageResource(R.drawable.story_next_arrow);
hidePrgressgingDailog();
} else if (ind > 0 && ind < items.size() - 1) {
previous.setEnabled(true);
next.setEnabled(true);
previous.setImageResource(R.drawable.story_previous_arrow);
next.setImageResource(R.drawable.story_next_arrow);
}
if (ind == items.size() - 1) {
previous.setEnabled(true);
next.setEnabled(false);
previous.setImageResource(R.drawable.story_previous_arrow);
next.setImageResource(R.drawable.navigator_next_disable);
hidePrgressgingDailog();
}
} catch (Exception e) {
Log.e("Error", "--,adjustButtonsVisibility Message = " + e);
e.printStackTrace();
}
}
Do this
if (ind == 0) {
previous.setEnabled(false);
previous.setImageResource(R.drawable.navigator_previous_disable);
next.setImageResource(R.drawable.story_next_arrow);
hidePrgressgingDailog();
}
else if (ind > 0 && ind < items.size() - 1) {
previous.setEnabled(true);
next.setEnabled(true);
previous.setImageResource(R.drawable.story_previous_arrow);
next.setImageResource(R.drawable.story_next_arrow);
}
else if (ind == items.size() - 1) {
previous.setEnabled(true);
next.setEnabled(false);
previous.setImageResource(R.drawable.story_previous_arrow);
next.setImageResource(R.drawable.navigator_next_disable);
hidePrgressgingDailog();
}