我对EditText有一个(?简单?)问题.每当我输入它时,即使我到达屏幕边缘而不是创建新行,文本也会保持在同一行.我确定我以前记得它默认这样做,但我似乎无法让它工作知道...
<EditText
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/hint"
android:inputType="textCapSentences" />
Run Code Online (Sandbox Code Playgroud)
编辑:问题是因为有一个android:inputType.有没有办法让输入类型有多行?
我正在尝试在我的首选项屏幕中创建一个NumberPicker对话框.我已经在此之后做了一个:https://stackoverflow.com/a/5533295/2442638
但是,对于我的第二个对话框,我只想要一个微调器,所以我调整了代码如下:
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.NumberPicker;
public class SnoozeTPP extends DialogPreference {
private int Minute = 0;
private NumberPicker np= null;
public static int getMinute(String time) {
String[] pieces = time.split(":");
return (Integer.parseInt(pieces[1]));
}
public SnoozeTPP(Context context, AttributeSet attrs) {
super(context, attrs);
setPositiveButtonText("Set");
setNegativeButtonText("Cancel");
}
@Override
protected View onCreateDialogView() {
np = new NumberPicker(getContext());
return (np);
}
@Override
protected void onBindDialogView(View v) {
super.onBindDialogView(v);
np.setMaxValue(60);
np.setValue(Minute);
} …
Run Code Online (Sandbox Code Playgroud) 我通过使用格式化来保存日期SimpleDateFormat
.
DateFormat dateForm = new SimpleDateFormat("HH mm ss dd MMM ''yy");
String dateOutput = dateForm.format(new Date());
Run Code Online (Sandbox Code Playgroud)
这使用设备的默认语言环境,例如法语或西班牙语.
如何将此字符串(格式化为不同的Locale)转换回Date
格式为Locale.ENGLISH
?的对象?
目前,当我尝试将字符串转换回日期时,我得到一个不可解析的日期异常.这是由使用不同的区域设置保存日期的事实引起的
我最近在我的应用中更新了Google Play服务库,以使用新的Google API.这样,每当我第一次启动一个Activity(它扩展BaseGameActivity)而没有登录时,Activity会自动出现登录对话框.
我没有在任何beginUserInitiatedSignIn()
地方打过电话. 这很烦人 - 这有什么办法吗?
这是一个logcat:
03-02 21:13:08.067: W/PopupManager(12332): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.
03-02 21:13:08.137: D/dalvikvm(12332): GC_FOR_ALLOC freed 223K, 3% free 9306K/9560K, paused 16ms, total 16ms
03-02 21:13:08.197: I/Adreno-EGL(12332): <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13
03-02 21:13:08.228: D/OpenGLRenderer(12332): Enabling debug mode …
Run Code Online (Sandbox Code Playgroud) 正如标题所述; 有没有办法比较时间,看看它们是否在彼此的一定时间内?IE浏览器.判断Time1是否在Time2的15分钟内的方法.一个更复杂的例子可能是在75分钟内(因为小时也会改变,因此将分钟数重置为0.
在java/android中有很多不同的比较日期和时间的方法.有Time
班级,Date
班级和Calendar
班级.甚至还有一种compareTo
方法和方法可以检查日期是在另一个之前还是之后,但我无法找到解决问题的方法.
另一个例子:
如果我有Time1,12:30和Time2,12:10,我想检查他们是否还有15分钟的时间.我可以比较分钟差异的差异.30 - 10 = 20. 20显然不低于15.
但是,Time1是12:56而Time2是13:02,这种方法不起作用.2 - 56 = -54,但实际差异为6.一种解决方案是,如果您知道以后哪个时间,请检查后一分钟是否小于前一分钟.如果不是,则在前一分钟添加60.
这是比较好的方法吗?这会给我的代码增加很多复杂性,特别是当我需要检查小时和日期时.是否有更简单的解决方案或api可用?
我有一个包含a 的Fragment
被叫.其中的项目由另一个叫做的类添加.我想要做的是在项目添加到列表时保存列表.(目前,我的列表中的视图只是s,但后来我希望向它们添加图像,并且有多行等等,所以这些也需要保存).我的列表是:它被调用.HistoryFragment
ListView
ListView
DataModel
TextView
ArrayList<Map<String, String>>
mPlanetList
我认为保存到a SQLiteDataBase
是解决方案,但即使在阅读了多个答案/教程后看起来也很复杂.
我看过的一些网站:
http://www.vogella.com/articles/AndroidSQLite/
http://developer.android.com/guide/topics/data/data-storage.html#db
http://stackoverflow.com/q/5482402/2442638
http://stackoverflow.com/q/3142285/2442638
Run Code Online (Sandbox Code Playgroud)
这个"问题"中有很多问题,但我的主要问题分为两部分:
a)是DataBase
正确的解决方案吗?
- >如果'是' - > b)制作一个简单的方法是什么?我宁愿不使用JSON/GSON
- >如果'不' - > c)我应该使用什么? SharedPreferences
?
假设a DataBase
是正确的解决方案,我想我需要序列化我的arraylist或者可能使用StringSet - 我不知道怎么做,因为我有这样的arraylist:ArrayList<Map<String, String>>
而不是没有map对象的arraylist.
此外,我试图从我的DataModel
类访问我的数据库(因为这是我将我的项目添加到列表中),但我无法让它工作.
我已经添加了我当前的代码 - 数据库的工作还没有完成,但我仍然坚持下一步该做什么.
这是我的HistoryFragment
班级:
// Remove imports
public class HistoryFragment extends FragmentBase implements OnItemAddedHandler {
// FragmentBase is just another class which extends Fragment and the moment.
ListView lv;
SimpleAdapter simpleAdpt; …
Run Code Online (Sandbox Code Playgroud) 例如,如果我有30个按钮,并且我想OnClickListener
为每个按钮添加一个,我是否必须button.setOnClickListener(this);
为每个按钮手动执行?这看起来非常混乱.
是否可以使用循环或其他东西?
android ×7
android-date ×2
date ×1
dialog ×1
google-plus ×1
java ×1
locale ×1
newline ×1
numberpicker ×1
string ×1
time ×1