I want the dialog to show the correct text based on the selected option (ie. If pressed TWO I want is to show the text "you pressed TWO")
on the first press it seemingly does nothing the text goes to the initialized
on the second press you find out the text was switched to default
I'm new to android and I don't think I understand what the activity is doing here.
Can someone please help me find a way that works?
public class AndMainT extends Activity {
private GameLogicT myGame = new GameLogicT();
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b_com = (Button)findViewById(R.id.button);
b_com.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CharSequence[] pick_one = {"ONE", "TWO", "THREE"};
call_menu(pick_one);
updateAwesomeText();
}
});
}
public void updateAwesomeText(){
TextView newText = (TextView)findViewById(R.id.text);
newText.setText(myGame.getCurrent_opt().getDescription() + "\n");
}
public void call_menu(CharSequence[] items){
final CharSequence[] f_items = items;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Orders Captain?");
builder.setItems(f_items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
myGame.startOpt(item);
}
});
builder.show();
}
}
public class GameLogicT {
class GOpt{
private CharSequence description = "this is the intialized text sadface";
public CharSequence getDescription() {
return description;
}
public void setDescription(CharSequence description) {
this.description = description;
}
}
private GOpt current_opt = new GOpt();
public void startOpt(int item){
switch(item){
case 1:
current_opt.setDescription("you pressed ONE");
case 2:
current_opt.setDescription("you pressed TWO");
case 3:
current_opt.setDescription("you pressed THREE");
default:
current_opt.setDescription("I am a fart and think you have pressed nothing sadface");
}
}
public GOpt getCurrent_opt() {
return current_opt;
}
public void setCurrent_opt(GOpt current_opt) {
this.current_opt = current_opt;
}
}
I also tried
public void onClick(View v) {
CharSequence[] pick_one = {"ONE", "TWO", "THREE"};
call_menu(pick_one);
try {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
updateAwesomeText();
}
public void onClick(DialogInterface dialog, int item) {
myGame.startOpt(item);
notify();
}
This causes a force close when the button is pressed, it's not my question just saying I tried!
sorry but I can't test your code due a lot of work.
However,after taking a look I noticed the following:
1) I think that position of items starts from index 0.
2) Maybe you lost some break in the switch-casestatement
So, try to replace it with:
public void startOpt(int item){
switch(item){
case 0:
current_opt.setDescription("you pressed ONE");
break;
case 1:
current_opt.setDescription("you pressed TWO");
break;
case 2:
current_opt.setDescription("you pressed THREE");
break;
default:
current_opt.setDescription("I am a fart and think you have pressed nothing sadface");
}
}
Hope it helps you!
Related
I have a RecyclerView list that displays an item which houses some TextViews and Buttons. I have already linked the buttons of each item to a specific function. The fragment looks like this.
The two buttons (Red and Blue) changes its function based on the user's status. e.g. when a user is not approved, the blue button will show "Activate Account" and the red button will show "Remove Request", each with their own function. All the functions of the button work as intended, but there is a slight problem. When I click on one of the two buttons, it sometimes won't register the click. I think it might have to do with the RecyclerView's scrolling property. Is there any way to overcome this problem? I want those buttons to function as normal buttons that when the buttons are touched, it will always register as a button click, not a recyclerview drag.
RecyclerView Adapter:
class AccountViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView text_name;
TextView text_username;
TextView text_status1; // Approved | Pending
TextView text_status2; // Admin
TextView text_status3; // Operator
Button button_left; // Deactivate | Remove Request
Button button_right; // Admin | Activate
private WeakReference<AccountListClickListener> listenerRef;
public AccountViewHolder(#NonNull View itemView, AccountListClickListener clickListener) {
super(itemView);
listenerRef = new WeakReference<>(clickListener);
text_name = itemView.findViewById(R.id.acc_name);
text_username = itemView.findViewById(R.id.acc_username);
text_status1 = itemView.findViewById(R.id.acc_status);
text_status2 = itemView.findViewById(R.id.acc_status2);
text_status3 = itemView.findViewById(R.id.acc_status3);
button_left = itemView.findViewById(R.id.button_left);
button_right = itemView.findViewById(R.id.button_right);
button_left.setOnClickListener(this);
button_right.setOnClickListener(this);
}
#Override
public void onClick(View view) {
if (view.getId() == button_left.getId())
listenerRef.get().leftButtonClick(getAdapterPosition(), button_left.getText().toString(), text_username.getText().toString().substring(10));
if (view.getId() == button_right.getId())
listenerRef.get().rightButtonClick(getAdapterPosition(), button_right.getText().toString(), text_username.getText().toString().substring(10));
}
}
public void setFilter(int i){
this.statusFilter = i;
}
}
RecyclerView Fragment
public class AccountFragment extends Fragment implements RadioGroup.OnCheckedChangeListener {
private RecyclerView recyclerView;
private List<Account> accountList;
private AccountAdapter accountAdapter;
private Timer timer;
private View view;
private boolean isActive;
private RadioGroup rg1, rg2;
private int filter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
isActive = true;
return inflater.inflate(R.layout.fragment_account, container, false);
}
#Override
public void onViewCreated(#NonNull final View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
this.view = view;
accountList = new ArrayList<>();
rg1 = view.findViewById(R.id.fg_acc1);
rg2 = view.findViewById(R.id.fg_acc2);
rg1.setOnCheckedChangeListener(this);
rg2.setOnCheckedChangeListener(this);
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
#Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
#Override
public void run() {
if(isActive) {
((MainActivity) getActivity()).populateAccountCards();
}
}
});
}
}, 0, 100);
final DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("account");
ref.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot snapshot) {
for (DataSnapshot snap : snapshot.getChildren()){
accountList.add(snap.getValue(Account.class));
}
accountAdapter = new AccountAdapter(view.getContext(), accountList, new AccountAdapter.AccountListClickListener() {
#Override
public void leftButtonClick(int i, String button, String username) {
switch(button){
case "DEACTIVATE ACCOUNT":
modifyAccount(ref, 0, username);
break;
case "REMOVE REQUEST":
modifyAccount(ref, 1, username);
break;
}
}
#Override
public void rightButtonClick(int i, String button, String username) {
switch(button){
case "REMOVE AS ADMIN":
modifyAccount(ref, 2, username);
break;
case "MAKE ADMIN":
modifyAccount(ref, 3, username);
break;
case "ACTIVATE ACCOUNT":
modifyAccount(ref, 4, username);
break;
}
}
});
recyclerView = view.findViewById(R.id.recyclerView2);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
recyclerView.setAdapter(accountAdapter);
}
#Override
public void onCancelled(#NonNull DatabaseError error) {
}
});
}
public AccountAdapter getAccountAdapter(){
return this.accountAdapter;
}
/*
0 - Deactivate Account
1 - Remove Account
2 - Remove as Admin
3 - Make Admin
4 - Activate Account
*/
private void modifyAccount(DatabaseReference ref, final int i, final String user) {
final Fragment currentFragment = getActivity().getSupportFragmentManager().findFragmentById(R.id.fragment_container);
final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
DatabaseUtil.readDataByUsername(user, ref, new OnGetDataListener() {
#Override
public void dataRetrieved(final DataSnapshot dataSnapshot) {
switch(i){
case 0:
DialogInterface.OnClickListener dialogClickListener1 = new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
dataSnapshot.getRef().child("activated").setValue(false);
dataSnapshot.getRef().child("admin").setValue(false);
fragmentTransaction.detach(currentFragment);
fragmentTransaction.attach(currentFragment);
fragmentTransaction.commit();
break;
case DialogInterface.BUTTON_NEGATIVE:
Toast.makeText(getContext(), "Action Cancelled", Toast.LENGTH_LONG).show();
break;
}
}
};
AlertDialog.Builder builder1 = new AlertDialog.Builder(getContext());
builder1.setMessage("Deactivate Account of " + user + "?").setPositiveButton("Yes", dialogClickListener1)
.setNegativeButton("No", dialogClickListener1).show();
break;
case 1:
DialogInterface.OnClickListener dialogClickListener2 = new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
dataSnapshot.getRef().removeValue();
fragmentTransaction.detach(currentFragment);
fragmentTransaction.attach(currentFragment);
fragmentTransaction.commit();
break;
case DialogInterface.BUTTON_NEGATIVE:
Toast.makeText(getContext(), "Action Cancelled", Toast.LENGTH_LONG).show();
break;
}
}
};
AlertDialog.Builder builder2 = new AlertDialog.Builder(getContext());
builder2.setMessage("Delete Account of " + user + "?\nWARNING: ALL DATA WILL BE LOST").setPositiveButton("Yes", dialogClickListener2)
.setNegativeButton("No", dialogClickListener2).show();
break;
case 2:
DialogInterface.OnClickListener dialogClickListener3 = new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
dataSnapshot.getRef().child("admin").setValue(false);
fragmentTransaction.detach(currentFragment);
fragmentTransaction.attach(currentFragment);
fragmentTransaction.commit();
break;
case DialogInterface.BUTTON_NEGATIVE:
Toast.makeText(getContext(), "Action Cancelled", Toast.LENGTH_LONG).show();
break;
}
}
};
AlertDialog.Builder builder3 = new AlertDialog.Builder(getContext());
builder3.setMessage("Remove Admin Access of " + user + "?").setPositiveButton("Yes", dialogClickListener3)
.setNegativeButton("No", dialogClickListener3).show();
break;
case 3:
DialogInterface.OnClickListener dialogClickListener4 = new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
dataSnapshot.getRef().child("admin").setValue(true);
fragmentTransaction.detach(currentFragment);
fragmentTransaction.attach(currentFragment);
fragmentTransaction.commit();
break;
case DialogInterface.BUTTON_NEGATIVE:
Toast.makeText(getContext(), "Action Cancelled", Toast.LENGTH_LONG).show();
break;
}
}
};
AlertDialog.Builder builder4 = new AlertDialog.Builder(getContext());
builder4.setMessage("Grant Admin Access to " + user + "?").setPositiveButton("Yes", dialogClickListener4)
.setNegativeButton("No", dialogClickListener4).show();
break;
case 4:
DialogInterface.OnClickListener dialogClickListener5 = new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
dataSnapshot.getRef().child("activated").setValue(true);
fragmentTransaction.detach(currentFragment);
fragmentTransaction.attach(currentFragment);
fragmentTransaction.commit();
break;
case DialogInterface.BUTTON_NEGATIVE:
Toast.makeText(getContext(), "Action Cancelled", Toast.LENGTH_LONG).show();
break;
}
}
};
AlertDialog.Builder builder5 = new AlertDialog.Builder(getContext());
builder5.setMessage("Activate Account of " + user + "?").setPositiveButton("Yes", dialogClickListener5)
.setNegativeButton("No", dialogClickListener5).show();
break;
}
}
#Override
public void dataExists(DataSnapshot dataSnapshot) {
}
#Override
public void onStart() {
}
#Override
public void onFailure() {
}
});
}
I solved it! Apparently I have a timer thread that runs at a fixed interval which calls a function to populate the cards and filter the items based on the radiobutton filter selected. The timer executes that function every 100 milliseconds that updates the item adapter, which doesn't give the system enough time to register the button press. Changing the timer interval to a longer duration solved the problem.
It made sense as when I touch the button for more than 100 milliseconds, the system wouldn't recognize that I touched the original button anymore because it already populated a new set of viewholders and ultimately, the button I was touching was now gone, along with its onclick function.
I have 2 Activities A(user input) and B (Display based on user input). Where in Activity A, i am selecting multiple values from alert dialog and put it in arraylist then pass it on to the activity B. So when i want to change the values i need to comeback to Activity A and i can reselect. But When i am reselecting the value or removing any values the older selected values are also exist so that my Arraylist is keep on growing. Please help.
Activity A:
public class AllMovieRating extends ActionBarActivity implements View.OnClickListener {
private Views mViews;
final ArrayList ilist = new ArrayList();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_all_movie_rating);
mViews=new Views();
mViews.irating.setOnClickListener(this);
}
#Override
public void onClick(View v) {
switch (v.getId()){
case R.id.imdb_rating:
ilist();
break;
}
}
private void filtervalues() {
Intent intent = new Intent(AllRating.this,sharedcollect.class);
intent.putExtra("im",ilist);
startActivity(intent);
}
public ArrayList ilist() {
final CharSequence[] ratings = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
final boolean[] ratingschecked = {false, false, false, false, false, false, false, false, false, false};
SharedPreferences sharedPreferences = this.getSharedPreferences("checkedrate_i", Context.MODE_PRIVATE);
final SharedPreferences.Editor editor = sharedPreferences.edit();
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
int size = sharedPreferences.getInt("size", 0);
for(int j=0;j<size;j++)
{
ilist.add(sharedPreferences.getString("selectedratings" + j, null));
//Log.e("Kumar", "" + selectedratings);
}
for(int j=0;j<=ratingschecked.length;j++){
if(ilist.contains((String.valueOf(j)))) {
ratingschecked[j-1] = true;
}
}
builder.setTitle("Select Ratings");
builder.setMultiChoiceItems(ratings, ratingschecked, new DialogInterface.OnMultiChoiceClickListener() {
#Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if (isChecked) {
if(!ilist.contains((String)String.valueOf(ratings[which]))){
ilist.add(String.valueOf(ratings[which]));
ratingschecked[which]=true;
}
} else if ((ilist.contains((String)String.valueOf(ratings[which])))) {
ilist.remove(String.valueOf(ratings[which]));
// Log.e("Kumar", String.valueOf(ratings[which]));
ratingschecked[which]=false;
}
}
}).setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// editor.putString("checked", String.valueOf(selectedratings));
for (int i = 0; i < ilist.size(); i++) {
editor.putString("selectedratings" + i, String.valueOf(ilist.get(i)));
}
editor.putInt("size", ilist.size());
editor.apply();
//Log.e("Shiva", String.valueOf(selectedratings));
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog dialog = builder.create();
builder.show();
return ilist;
}
Activity B:
public class sharedcollect extends ActionBarActivity {
ListView movielist;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sharedcollect);
Intent i = getIntent();
ArrayList<String> list = i.getStringArrayListExtra("im");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_sharedcollect, menu);
return true;
}
#Override
public void onBackPressed() {
//do whatever to save the settings
moveTaskToBack(true);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch (item.getItemId()){
case R.id.action_settings:
Intent intent = new Intent(sharedcollect.this,AllMovieRating.class);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
} }}
Tried using OnBackPressed() inside onOptionsItemSelected(MenuItem item) in Activity B but that doesn't helped. How can i control array list so that i will send only the selected items.
You will need to clear the array Before every reselecting in Activity A.
ilist.clear();
In your case my guess is to do add the following in your Activity A.
EDITED:
#Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.imdb_rating:
ilist.clear();
ilist();
break;
}}
I would like to implement products list with checklistbox after select radio button.
And I would like to show chekclistbox as dialog box. My product list data come from sqllite.
It is need to implement adapter class to show data for checklistbox or can I directly implement for checklistbox data in alertDialog . Please clear for me.
In mainActivity
public RadioGroup.OnCheckedChangeListener setOnCheckedChangeListener = new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
rdoPCode = (RadioButton) findViewById(checkedId);
switch (checkedId) {
case R.id.rdoAll:
Toast.makeText(context, rdoPCode.getText(), Toast.LENGTH_SHORT)
.show();
break;
case R.id.rdoCustom:
Intent localIntent = new Intent(MainActivity.context,
ProductListChkActivity.class);
MainActivity.context.startActivity(localIntent);
break;
}
}
};
In ProductListChkActivity
public class ProductListChkActivity extends Activity {
private static Button button_selectall;
private static Button button_unselectall;
private static CheckBox chkProductCode;
private static CashSaleProductLogic _sellProductLogic;
public static List<CashSaleProductInfo> _SaleProductInfo;
public static ListView lvlchkPrdlist;
private Button btnSelectAll, btnUnSelectAll;
// For chk productcode
private static ProductListChkAdapter _ProductListChkAdapter;
Context context;
#Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.productinofchk);
context = this;
init();
ProductCodeChk();
}
private void init() {
button_selectall = (Button) this.findViewById(R.id.button_selectall);
button_unselectall = (Button) this
.findViewById(R.id.button_unselectall);
chkProductCode = (CheckBox) this.findViewById(R.id.chkProductCode);
lvlchkPrdlist = (ListView) this.findViewById(R.id.lvlchkPrdlist);
_sellProductLogic = new CashSaleProductLogic(this);
_SaleProductInfo = _sellProductLogic.getAllsellProductDataLogic();
}
protected void ProductCodeChk() {
try {
_ProductListChkAdapter = new ProductListChkAdapter(context,
_SaleProductInfo, 1);
this.lvlchkPrdlist.setAdapter(_ProductListChkAdapter);
} catch (Exception e) {
e.printStackTrace();
return;
}
}
public void OnClickbillbtncancel(View paramView) {
MainActivity.textClear();
Intent localIntent = new Intent(ProductListChkActivity.this,
MainActivity.class);
ProductListChkActivity.this.startActivity(localIntent);
}
}
I would like to show productinofchk layout as dialogbox
You need to go through floating dialogs in android. check out this documentation :
link
I know this has been asked a million times but none have led me to solving my problem. The onclicklistener will not activate the code for any of the buttons. Here are the different sections that apply to the five buttons.
Button btnGuysMax;
Button btnGuysMedium;
Button btnEven;
Button btnGirlsMedium;
Button btnGirlsMax;
....
private void init()
{
datasource = new BarsDataSource(this);
datasource.open();
Intent intent = getIntent();
long id = intent.getLongExtra("bar_id",0);
bar = datasource.getBarById(id);
title = (TextView)findViewById(R.id.title);
btnGuysMax = (Button)findViewById(R.id.btnGuysMax);
btnGuysMedium = (Button)findViewById(R.id.btnGuysMedium);
btnEven = (Button)findViewById(R.id.btnEven);
btnGirlsMedium = (Button)findViewById(R.id.btnGirlsMedium);
btnGirlsMax = (Button)findViewById(R.id.btnGirlsMax);
......
btnGuysMax.setOnClickListener(this);
btnGuysMedium.setOnClickListener(this);
btnEven.setOnClickListener(this);
btnGirlsMedium.setOnClickListener(this);
btnGirlsMax.setOnClickListener(this);
.....
#Override
public void onClick(View view)
{
//resetButtons();
switch (view.getId()) {
case R.id.btnGuysMax:
//bar.setSexRatio(-2);
//btnGuysMax.setBackgroundColor(guysMaxColor);
Toast.makeText(this,"Max clicked!",Toast.LENGTH_LONG);
break;
case R.id.btnGuysMedium:
bar.setSexRatio(-1);
Toast.makeText(this,"Medium clicked!",Toast.LENGTH_LONG);
//btnGuysMedium.setBackgroundColor(guysMediumColor);
break;
case R.id.btnEven:
bar.setSexRatio(0);
//Toast.makeText(this,"Medium clicked!",Toast.LENGTH_LONG);
break;
case R.id.btnGirlsMedium:
bar.setSexRatio(1);
//btnGirlsMedium.setBackgroundColor(girlsMediumColor);
break;
case R.id.btnGirlsMax:
bar.setSexRatio(2);
break;
.....
To display a toast you need to call show method.
Try:
Toast.makeText(this,"message",Toast.LENGTH_LONG).show();
try doing:
#Override
public void onClickListener(View view)
{
instead of:
#Override
public void onClick(View view)
{
The dialog:
public class ClearDialog extends Dialog {
private MainActivity context;
public ClearDialog(MainActivity context) {
super(context);
this.context = context;
setContentView(R.layout.clear_dialog);
setTitle("something");
setCanceledOnTouchOutside(false);
setCancelable(true);
}
/* not overriding anymore
#Override
public void onBackPressed() {
return;
}
still doesnt work */
#Override
protected void onStart() {
super.onStart();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = preferences.edit();
editor.clear();
editor.commit();
ResourceHelpers.removeAllResources();
context.onResourcesDeleted();
}
}
The Activity:
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.itemLogoff:
loginDialog.show(); //this is another dialog
break;
case R.id.itemSync:
Intent syncer = new Intent(MainActivity.this, SyncActivity.class);
MainActivity.this.startActivity(syncer);
break;
case R.id.itemClear:
new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_action_alert)
.setTitle("something")
.setMessage("something")
.setPositiveButton("something", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
showDeleteDialog();
}
})
.setNegativeButton("something", null)
.show();
break;
}
return true;
}
private void showDeleteDialog() {
cd = new ClearDialog(this); //this is the dialog
cd.show();
}
public void onResourcesDeleted() {
cd.dismiss();
loginDialog.show();
}
So.. The user clicks on "Delete all data" from the ActionBar (optionsmenu). I open an AlertDialog asking if he's sure. Then if he's sure, I open a dialog that shows a spinning ProgressBar.
The problem: it won't dismiss!
The loginDialog (all data is lost so I want the user to login again...) comes up in the background. The ClearDialog won't dismiss...
I think that the problem is here (don't override in this way that method):
#Override
public void onBackPressed() {
return;
}
You can already obtain a modal dialog with .setCancelable(false)
Please take a loog at this documentation: http://developer.android.com/guide/topics/ui/dialogs.html#AlertDialog
Give the following property for dialogue
.setCancelable(true);
its just like .setTitle() or .setMessage in your code....
On top of StErMi's answer, which you should follow, also switch the two lines in your onResourcesDeleted() method. The login dialog is called, and takes over before your dismiss is called.
public void onResourcesDeleted() {
cd.dismiss();
loginDialog.show();
}