我正在为进度对话框设置一个drawable(pbarDialog)但我的问题是我想每次调整drawable的大小但是无法弄清楚如何.
这是一些代码:
Handler progressHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
// some more code
case UPDATE_PBAR:
pbarDialog.setIcon(mAppIcon);
pbarDialog.setMessage(mPbarMsg);
pbarDialog.incrementProgressBy(mIncrement+1);
break;
}
}
};
pbarDialog.show();
Thread myThread = new Thread(new Runnable() {
public void run() {
// some code
for (int i = 0; i < mApps.size(); i++) {
mAppIcon = mAdapter.getIcons().get(mApps.get(i).getPackageName());
// need to resize drawable here
progressHandler.sendEmptyMessage(UPDATE_PBAR);
}
handler.sendEmptyMessage(DISMISS_PBAR);
}
});
myThread.start();
Run Code Online (Sandbox Code Playgroud) Hay,我正在编写一些模板,但我想在字符串中将""转换为"_".
我想转换输出
{{ user.name }}
Run Code Online (Sandbox Code Playgroud)
从"我的名字"到"我的名字"之类的东西.我该怎么做呢?
我想通过单击弹出窗口外部或后退按钮来关闭弹出窗口,但是当单击后退按钮我的应用程序退出时,而不是退出应用程序我想要关闭弹出窗口.
这是我的代码,
ivmainmenu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popupwindow, null);
final PopupWindow popupWindow = new PopupWindow(popupView,LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
popupWindow.showAsDropDown(ivmainmenu, 0,14);
popupView.setPadding(0, 0, 0, 10);
popupWindow.showAsDropDown(ivmainmenu);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(false);
TextView tvpopupwork = (TextView)popupView.findViewById(R.id.tvpopupwork);
TextView tvpopupabout = (TextView)popupView.findViewById(R.id.tvpopupabout);
TextView tvpopupservices = (TextView)popupView.findViewById(R.id.tvpopupservices);
TextView tvpopupcontact = (TextView)popupView.findViewById(R.id.tvpopupcontact);
Typeface typeFace2 = Typeface.createFromAsset(getAssets(),"fonts/arboriaboldregular.ttf");
tvpopupwork.setTypeface(typeFace2);
tvpopupabout.setTypeface(typeFace2);
tvpopupservices.setTypeface(typeFace2);
tvpopupcontact.setTypeface(typeFace2);
tvpopupwork.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method …Run Code Online (Sandbox Code Playgroud) 在Clojure中,何时以及为什么要使用命名的匿名函数?例如,
((fn add-five [x] (+ x 5)) 3))
Run Code Online (Sandbox Code Playgroud)
在ClojureDocs中,一个例子的评论说它在堆栈跟踪中很有用.可以举个例子吗?
在模型中:
class Getdata(models.Model):
title = models.CharField(max_length=255)
state = models.CharField(max_length=2, choices=STATE, default="0")
name = models.ForeignKey(School)
created_by = models.ForeignKey(profile)
def __unicode__(self):
return self.id()
Run Code Online (Sandbox Code Playgroud)
在模板中:
<form>
<input type="submit" value="save the data" />
</form>
Run Code Online (Sandbox Code Playgroud)
如果用户单击保存按钮并且上述数据保存在表中,如何避免重复,即如果用户再次单击相同的提交按钮,则不应该有相同值的另一个条目.或者它是否必须在视图中处理?
我有一个元素,我需要使其可选.
<xs:element name="Version" type="xs:string" minOccurs="1" />
Run Code Online (Sandbox Code Playgroud)
除了制作之外还有其他方法minOccurs="0"吗?
我已经为布尔值和字符串值创建了共享首选项.布尔值在另一个活动中获得.但对于字符串我只获得默认值.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor spe = prefs.edit();
spe.putBoolean("flag", true);
spe.putString("user", "hello");
spe.commit();
Run Code Online (Sandbox Code Playgroud)
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean flag= prefs.getBoolean("flag", false);
String user=prefs.getString("user","Nothing");
TextView tv = new TextView(this);
tv.setText("Flag : "+flag+(" User : "+user);
Run Code Online (Sandbox Code Playgroud)
对于"用户",仅显示"无".我应该在哪里更正我的代码?
我对Django比较新,我有一个简单的问题.在我的模板中,我有:
{% for article in article_list %}
<li>
{% for author in article.authors.all %}
{{ author.name }},
{% endfor %}
{{ article.title }}
</li>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我想要的是能够迭代author.name,但姓氏应该以句点而不是逗号结束.我是否必须返回视图才能实现此目的,或者模板中是否有一些简单的方法?
我在创造一个游戏.当我正在阅读LinkedHashMap时,它给了我一个NPE.
我这样填写LinkedHashMap hm:
for (String s : line.split("")) {
if (s.contains("*")) {
hm.put(new Coordinates(xa-32, ya), "gray");
} else if (s.contains("#")) {
hm.put(new Coordinates(xa-32, ya), "black");
}
// other code...
}
Run Code Online (Sandbox Code Playgroud)
后来我尝试从这样的HashMap中获取颜色,并得到一个NPE:
if ((keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_A)
&& isPainted && hm.get(new Coordinates(x - 32, y)).equalsIgnoreCase("gray")) {
x -= 32;
}
Run Code Online (Sandbox Code Playgroud)
完整代码: