0
因此,系統會提示用戶輸入文件名並將文件保存到外部存儲器。完成此操作後,我會調用另一種方法保存到Dropbox。這會創建另一個對話框一個簡單的「是/否」,用戶可以接受或拒絕保存到Dropbox。對話框失去焦點?整個屏幕「變灰」
當文件已保存到外部存儲器時,Dropbox對話框會顯示,但整個屏幕呈灰色,就像它失去了焦點。在屏幕上點擊使其恢復正常,所有的功能都可以,但是很煩人。下面的代碼和截圖。
private void saveToSD(){
//Build dialog etc
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Save file to phone and then...
saveToDropbox();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
而且saveToDropbox();
方法...
private void saveToDropbox(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
if (mDbxAcctMgr.hasLinkedAccount()){
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Upload to Dropbox")
.setMessage("Do you want to upload the file to Dropbox?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "This is when we would save to Dbx", Toast.LENGTH_LONG).show();
}
})
.setNegativeButton("No", null)
.show();
builder.show();
}else{
Toast.makeText(getApplicationContext(), "Not linked to Dropbox", Toast.LENGTH_LONG).show();
}
}