我有一个ProgressDialog,我想在对话框消失时做一些事情(但我不希望在progressdialog.dismiss之后执行我的操作).
是否有可能:
----> if No ---> Do something
Check if dialog is showing
----> if Yes
/|\ |
| \|/
--------------------- Wait
Run Code Online (Sandbox Code Playgroud)
不要认为很难,我只是想执行一个动作,但只有在没有对话框的情况下,如果有的话,才能在对话框完成时执行动作.谢谢!
编辑:我的活动:
import verymuchimportshere..
public class ScroidWallpaperGallery extends Activity {
private WallpaperGalleryAdapter wallpaperGalleryAdapter;
private final WallpaperManager wallpaperManager;
private final ICommunicationDAO communicationDAO;
private final IFavouriteDAO favouriteDAO;
private final List<Integer> preloadedList;
private Wallpaper selectedWallpaper;
private static final int PICK_CONTACT = 0;
private static final int DIALOG_ABOUT = 0;
public ScroidWallpaperGallery() {
super();
if (!DependencyInjector.isInitialized()) {
DependencyInjector.init(this);
}
this.wallpaperManager = DependencyInjector.getInstance(WallpaperManager.class); …Run Code Online (Sandbox Code Playgroud) 想象一下,我有一个像这样的文本文件:
Welcome to the text file!
-------------------------
Description1: value1
Description2: value2
Description containing spaces: value containing spaces
Description3: value3
Run Code Online (Sandbox Code Playgroud)
将这些数据存储到文本文件中很容易,如下所示:
$file = 'data/preciousdata.txt';
// The new data to add to the file
$put = $somedescription .": ". $somevalue;
// Write the contents to the file,
file_put_contents($file, $put, FILE_APPEND | LOCK_EX);
Run Code Online (Sandbox Code Playgroud)
每次写入时都会有不同的描述和价值.
现在我想读取数据,所以你会得到这个文件:
$myFile = "data/preciousdata.txt";
$lines = file($myFile);//file in to an array
Run Code Online (Sandbox Code Playgroud)
可以说我只是在文本文件中写了"color:blue"和"taste:spicy".我不知道它们是哪一行,我想要检索"color:"描述的值.
编辑 我应该让PHP"搜索"文件,返回包含"描述"的行号,然后将该行放在一个字符串中并删除":"的所有内容?
我有这个文本文件:
foo: bar
el: macho
bing: bong
cake color: blue berry
mayo: ello
Run Code Online (Sandbox Code Playgroud)
我想要完成的是,如果我“寻找” foo,它会返回 bar(如果我寻找 bing,它应该返回 bong)。尝试完成此操作的一种方法是首先搜索文件,返回带有结果的行,将其放入字符串中并删除“:”之前的所有内容并显示该字符串。
// What to look for
$search = 'bing';
// Read from file
$lines = file('file.txt');
foreach($lines as $line)
{
// Check if the line contains the string we're looking for, and print if it does
if(strpos($line, $search) !== false)
echo $line;
$new_str = substr($line, ($pos = strpos($line, ',')) !== false ? $pos + 1 : 0);
}
echo "<br>";
echo "bing should …Run Code Online (Sandbox Code Playgroud) 我有一个Image Uri,使用以下方法检索:
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
Run Code Online (Sandbox Code Playgroud)
这对于需要图像URI等的Intent来说非常有用(所以我确定URI是有效的).
但现在我想将此Image URI保存到SDCARD上的文件中.这更加困难,因为URI并没有真正指向SDCARD或应用程序上的文件.
我是否必须首先从URI创建位图,然后将位图保存在SDCARD上,或者是否有更快的方法(最好是不需要先转换为位图的方法).
(我已经看过这个答案了,但它找不到找到的文件 - /sf/answers/919378211/)
我有一个对话框,当应用程序第一次启动时显示信息.由于这些天用户,总是点击"确定"而不阅读文本.我想在前5秒内禁用OK按钮(最好在里面倒计时).如何实现这一目标?
我的代码(不是很必要):
new AlertDialog.Builder(this)
.setMessage("Very usefull info here!")
.setPositiveButton("OK", new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((AlertDialog)dialog).getButton(which).setVisibility(View.INVISIBLE);
// the rest of your stuff
}
})
.show();
Run Code Online (Sandbox Code Playgroud)
我希望这对其他用户有帮助.
我发现Android Studio没有项目的导出功能(课程的.apk导出除外)。我想在线共享项目的副本,但我发现仅共享Workspace项目的副本并不理想,因为其中包含特定于项目位置的临时生成文件和配置。
如何优化和准备共享我的项目?
我有一个包含一定数字的两个字符串(假设它不高于10).
String five = "5";
String two = "2";
Run Code Online (Sandbox Code Playgroud)
我怎样才能将它们一起添加?
String seven = five + two;
Run Code Online (Sandbox Code Playgroud)
显然不起作用.
如何将两个数字相加并让输出为"7"?我是否必须先转换字符串(例如转换为int)?
我想在我的应用程序启动时调用一个方法.我知道用"oncreate"在android上很容易实现,但很奇怪,我找不到任何关于如何使用Java而不是在Android上实现这一点.