我正在开发一个Android应用程序,当我在Android手机上安装应用程序时,应用程序图标不会出现在应用程序部分.但它出现在应用程序管理器中,我可以进行卸载.谷歌搜索后,有人说我需要重建我的项目,并确保可绘制资源中的应用程序图标.我已经尝试过这个解决方案,问题仍然存在.我创建的清单文件如下:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.view" />
<data android:scheme="geo" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud) 我试图将日期字符串转换为java中的日期对象,而不管当前的系统日期格式如何.因为我想让我的自定义日期格式存储在数据库中.以下是我的代码,请指教我.
public static String dateToString(String date){
if(date.equals("")) return "";
if(date == null || date.length() == 0){
return "";
}
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
try {
Date l_date = format.parse(date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(l_date);
String year = String.format("%04d", calendar.get(Calendar.YEAR));
String month = String.format("%02d", calendar.get(Calendar.MONTH));
String day = String.format("%02d", calendar.get(Calendar.DATE));
return year + month + day;
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "";
}
}
Run Code Online (Sandbox Code Playgroud)
对于SimpleDateFormat,它只能解析我听到的编码格式.
dateToString("16/04/2015");
Run Code Online (Sandbox Code Playgroud)
它可以转换为上面的代码.但是,当我尝试使用以下格式
dateToString("Thursday, April 16, 2015");
Run Code Online (Sandbox Code Playgroud)
我去Unparseable日期:"2015年4月16日星期四"错误.
我必须 动态更改它Typeface
,EditText
并在字体更改时处理提示文本.我只是这样做:
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_textBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/textBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_date" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我的代码片段如下:
EditText textBox = (EditText) findViewById(R.id.textBox);
Typeface tf = Typeface.createFromAsset(this, "myfont.ttf");
textBox.setTypeface(tf);
String hintText = textBox.getHint().toString(); //Got NullPointerException here....
String newText = processText(hintText); //This will process the hint text;
textBox.setHint(newText);
Run Code Online (Sandbox Code Playgroud)
当我退出程序时,我得到以下异常:
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
请帮我解决这个问题.
在我的设置活动中,选择 ListPreference 以升序或降序对结果列表进行排序后,所选值不会出现在 ListPreference 中。这是我用于此列表首选项的代码。我还附上了这个问题的截图。请让我知道是什么问题以及我的错误是什么。
<ListPreference
android:title="@string/pref_calllog_sorting"
android:key="@string/pref_calllog_sorting_descending"
android:defaultValue="@string/pref_calllog_sorting_descending"
android:entryValues="@array/pref_calllog_sorting_values"
android:entries="@array/pref_calllog_sorting_options" />
Run Code Online (Sandbox Code Playgroud)
我正在制作一个自定义SeekBar,如下图所示.
在通过互联网搜索后,我无法找到满足此问题的最佳解决方案.以下代码是正常的SeekBar控件,请帮我改变上面的图像.
<SeekBar
android:id="@+id/seekBar"
android:layout_width="fill_parent"
android:layout_height="@dimen/sbumit_form_field_height"
android:layout_marginTop="@dimen/sbumit_form_field_top_mergin"
android:layout_marginLeft="@dimen/sbumit_form_field_side_mergin"
android:layout_marginRight="@dimen/sbumit_form_field_side_mergin"
android:max="6"/>
Run Code Online (Sandbox Code Playgroud)