我有一个可以创建并弹出DialogFragment的Fragment,但是当我点击后退按钮时,即使我显式调用setCancelable(false),它也会取消对话框; 我的DialogFragment有没有办法对后退按钮不敏感?
public class LoadingDialogFragment extends DialogFragment
{
String title;
String msg;
public LoadingDialogFragment()
{
this.title = "Loading...";
this.msg = "Please wait...";
}
public LoadingDialogFragment(String title, String msg)
{
this.title = title;
this.msg = msg;
}
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState)
{
final ProgressDialog dialog = new ProgressDialog(getActivity());
dialog.setTitle(title);
dialog.setMessage(msg);
dialog.setIndeterminate(true);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);
return dialog;
}
}
Run Code Online (Sandbox Code Playgroud)
我从AsyncTask创建DialogFragment:
private class GpsTask extends AsyncTask<String, Integer, Integer>
{
//ProgressDialog dialog;
@Override
protected void onPreExecute()
{
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
DialogFragment newFragment …Run Code Online (Sandbox Code Playgroud) android back-button fragment progressdialog android-asynctask
我正在尝试使用Jake Wharton的ActionBarSherlock来支持Android项目中的动作栏,一直到1.6
我越来越使用开始视频提供的关于常见问题的页面,但在视频2:25后,当他进口的项目,我得到> 200个编译器错误的整个巨大的名单,主要是处理一些@override东西.我通过以下方式解决了大部分错误:
右键单击项目>属性> Java编译器>编译器合规性级别:然后将其设置为1.6.
这迫使重建,突然间我只有54个错误.其中大多数是"R无法解析为变量",但最后5个都是"导入com.actionbarsherlock.R无法解析".我已经四处寻找,解决这个问题的常用方法如下:
" 确保您的资源没有错误 " - 我检查了/ res文件夹中没有任何问题
" 确保你没有导入android.R " - 我不是.我有:
import com.actionbarsherlock.R
Run Code Online (Sandbox Code Playgroud)
在我看来,包名称可能不正确,但事实并非如此.
" 简单地清理项目 " - 多次这样做都没有效果
" 确保eclipse能够生成R文件 " - 它可以在我刚刚制作的空白测试项目中
还有一些其他更具体的ActionBarSherlock修复:
" 确保您的targetSDK为11或更高 " - 它设置为13
" 确保项目是一个图书馆项目 " - 它是
我怎样才能摆脱这些错误?
在OL3中,我成功制作了一个有可移动标记的地图:
var mapVectorSource = new ol.source.Vector({
features: []
});
var mapVectorLayer = new ol.layer.Vector({
source: mapVectorSource
});
map.addLayer(mapVectorLayer);
function makeMovable(feature) {
var modify = new ol.interaction.Modify({
features: new ol.Collection([feature])
});
feature.on('change',function() {
console.log('Feature Moved To:' + this.getGeometry().getCoordinates());
}, feature);
return modify;
}
function createMarker(location, style){
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point(location)
});
iconFeature.setStyle(style);
return iconFeature
}
iconStyle = new ol.style.Style({
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
anchor: [0.5, 1],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',
src: '/static/img/marker-icon.png',
}))
}); …Run Code Online (Sandbox Code Playgroud) 我有一个dicts列表,可以是0到100个元素长.我想只查看前三个元素,如果列表中的元素少于三个,我不想抛出错误.我如何在python中干净利落地做到这一点?
伪代码:
for element in my_list (max of 3):
do_stuff(element)
Run Code Online (Sandbox Code Playgroud)
编辑:此代码有效但感觉非常不洁净.我觉得python有更好的方法来做到这一点:
counter = 0
while counter < 3:
if counter >= len(my_list):
break
do_stuff(my_list[counter])
counter += 1
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用AVR Studio 5使用基本的hello world代码对Atxmega64a1进行编程.我使用64位win7.我将芯片插入STK600以尝试编程.当我进入工具> AVR编程并选择工具时,我看到两个选项:模拟器和STK600(后面有一个长序列号).我将工具设置为STK600并选择正确的设备,将接口切换到JTAG,然后点击"应用"
AVR Studio冻结了片刻并说:
"无法连接到工具STK600(6&33ECC3F5&0&4)",具有以下详细信息:时间戳:2012-01-19 20:04:38.771严重性:错误ComponentId:20000 StatusCode:0
无法连接到工具上下文:'Atmel.VsIde.AvrStudio.Services.TargetService.TCF.Internal.Services.Remote.ToolProxy + ToolContext'.
我点击接近,再过几秒钟后得到第二个错误:
"无法获得JTAG菊花链设置." 具有以下详细信息:时间戳:2012-01-19 20:07:59.057严重性:错误ComponentId:20000 StatusCode:0
无法连接到工具上下文:'Atmel.VsIde.AvrStudio.Services.TargetService.TCF.Internal.Services.Remote.ToolProxy + ToolContext'.
这不是这个板子,因为它可以在朋友的电脑上运行,而且在使用JTAGICE MKII甚至Dragon时也会遇到同样的错误.知道它可能是什么?我已经尝试卸载并重新安装绝对一切.
android ×2
avr ×1
back-button ×1
fragment ×1
gis ×1
javascript ×1
openlayers ×1
openlayers-3 ×1
python ×1