我已阅读以下页面:
python小数 - 使用ROUND_HALF_UP舍入到最接近的整数美元(无分钱)
http://docs.python.org/library/decimal.html
我有以下代码:
total_num = Decimal(str(total/10))
total_num.quantize(Decimal('1'), rounding=ROUND_UP)
Run Code Online (Sandbox Code Playgroud)
但它总是四舍五入?所以,如果我有221,我希望它返回23.现在我得到22.有什么我对此有误解吗?
[编辑]
我将其更改为以下内容: total_num = int(math.ceil(float(total)/10))
我需要一个int
继续for
循环有一个range
.
我正在尝试在我的应用程序中设置一个设置屏幕,就像iPhone内部存在的设置一样.单击设置时,我们会看到带有圆边的不同部分,全部为白色,某些hte选项有箭头,有些是开/关按钮.
Apple是如何实现这一目标的?是一个UITableView
吗?有没有关于如何使选项看起来相似的文档?或者是否有Apple的设置屏幕实现的开源示例?
我想创建一个具有类似功能的设置屏幕,因此我想知道它是如何在设置屏幕上实现的.不幸的是,找不到这个搜索.
我在让GCM为我的应用程序工作时遇到问题.我的webapp正在使用django并使用以下应用程序:https://github.com/bogdal/django-gcm
我按照这些页面上的说明正确设置了API_KEY:http: //developer.android.com/google/gcm/index.html
我的清单上有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testapp"
android:launchMode="singleInstance"
android:versionCode="11"
android:versionName="1.2.0">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17"/>
<permission android:name="com.testapp.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- This app has permission to register with GCM and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="com.testapp.permission.C2D_MESSAGE"/>
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.MyTheme">
<receiver
android:name="com.testapp.pager.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.testapp"/>
</intent-filter>
</receiver> …
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
@interface MyCell : UITableViewCell<UITextFieldDelegate>
{
IBOutlet UITextField *txtFields;
}
- (IBAction)textFieldAction:(id)sender;
@property (nonatomic,retain) IBOutlet UITextField *txtFields;
@end
Run Code Online (Sandbox Code Playgroud)
我还有以下委托功能:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
return NO;
}
Run Code Online (Sandbox Code Playgroud)
但是,我注意到它永远不会被召唤.我从接口构建器以及代码中设置委托:[txtFields setDelegate:self];
但似乎都不起作用.我还缺少其他的东西吗?
我可以在Button
s等上放置徽章编号,但有没有关于如何在视图寻呼机上放置徽章编号的示例?对于按钮我正在创建一个具有适当背景资源的xml等,但我无法找到任何方法将它放在PagerSlidingTabStrip
.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:background="@drawable/badge"
android:gravity="center"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:text="2"
android:textColor="@color/WHITE"
android:textSize="12sp"
android:textStyle="bold"
android:visibility="gone" />
Run Code Online (Sandbox Code Playgroud)
我将值设置为gone
first并在需要时显示.有没有办法用视图寻呼机做到这一点?