我正在开发一个应用程序,我收到了错误.我输入了一些String资源res/values/strings并保存了它.现在如果我想在Activity中访问它,我会收到这样的错误
07-13 11:16:20.050: ERROR/AndroidRuntime(5883): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f060006
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚原因.资源看起来像这样:
<string name="dialog_download_text">please wait while downloading</string>
Run Code Online (Sandbox Code Playgroud)
我想像访问它一样
public void onCreate(Bundle b){
super.onCreate(b);
String s = getResources().getString(R.string.dialog_download_text);
}
Run Code Online (Sandbox Code Playgroud)
我也查看了R.java并找到了我的条目
public static final class string {
public static final int dialog_download_cancel=0x7f060005;
public static final int dialog_download_text=0x7f060007;
public static final int dialog_download_title=0x7f060006;
}
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么做,因为我之前从未遇到过这样的问题.请帮我.谢谢大家.
我有一个日期字符串2012-11-21 13:11:25,我从本地数据库.我必须根据UTC设置进行转换并将其显示在特定屏幕上.所以如果GMT+05:30它应该显示2012-11-21 18:41:25在屏幕上.我该怎么做这个转换.我已经检查了一些问题但是没有成功.
我能够得到一个Date对象,返回类似Wed Nov 21 13:11:25 GMT+05:30 2012 之后我需要得到的时间18:41:25和日期11-21-2012
提前致谢
我是Android新手,我正在努力Gestures.我有关于如何识别文本的问题.当用户绘制必须被识别并且必须打印在屏幕顶部的字母或数字时.我开始知道它可以通过GestureOverlayView但不知道如何实现它.
有人可以帮我一些示例代码.
我的应用程序中有一个登录页面,其中列出了以下元素:
按下时Login,它将进入主屏幕.当用户Done在软键盘上键入密码完成时点击时,执行相同的动作Samsung Galaxy S3; 和Enter软键盘上的键HTC One X.
那么,密码字段的EditText如何是:
<EditText
android:id="@+id/password_txt"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="8dp"
android:singleLine="true" />
Run Code Online (Sandbox Code Playgroud)
在活动中,无论我尝试了什么,都在这里:
EditText mPassword = (EditText) findViewById(R.id.password_txt);
mPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER || actionId == EditorInfo.IME_ACTION_DONE){
Log.e("MyApp", " ------> IN EDITOR ACTION DONE");
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
我确实尝试保持密码字段的imeOptions actionDone以及flagNoExtractUi …
android login keyevent android-softkeyboard android-edittext
我很擅长使用SearchView.我需要一个功能,我有一个ActionBar我有的功能Search.当我点击"搜索"时,建议应显示在"搜索"字段下方的列表中.
到目前为止我做了什么:
在menu.xml中添加了搜索,并onCreateOptionsMenu()在我初始化SearchView的地方编写了代码并setSuggestionsAdapter实现了setOnQueryTextListener.
结果:我进入应用程序,点击搜索图标,显示建议.我输入一个字母,对匹配的字母进行排序.我键入第二个字母,它没有显示建议.此外,我关闭搜索视图并再次打开它,键盘打开,但列表中的建议未显示.
我需要的:根据用户输入的字符进行过滤.即使它不止一个角色.始终显示建议,默认为一个包含所有列表项,或者是在用户类型时排序的建议.
我在Android的SearchView类中看到,他们将文本设置为空并且也忽略了建议.但我不想要这个.
我被困在这里,不知道如何继续.请帮我.这是我的适配器代码:
public class ExampleAdapter extends CursorAdapter implements Filterable {
private ArrayList<String> items;
private ArrayList<String> orig;
public ExampleAdapter(Context context, Cursor cursor,
ArrayList<String> items) {
super(context, cursor, false);
this.items = new ArrayList<String>();
this.items = items;
orig = new ArrayList<String>();
orig.addAll(items);
}
@Override
public int getCount() {
return items.size();
}
@Override
public Filter getFilter() {
return new Filter() { …Run Code Online (Sandbox Code Playgroud) 我有一个自定义的ListView.每行都有一个EditText, Buttons & TextView.为了使ListView项目可单击,我保留android:descendantFocusability="blocksDescendants"了行布局.如果我不保留descendantFocusability,我无法实现一个动作onItemClick.如果我保留了descendantFocusability,那么EditText我的行中存在的并没有获得焦点.我想要EditText焦点,我也应该能够点击每一行导航到另一行Activity.任何人都可以帮助我.谢谢大家.
编辑:在EditText的CustomAdapter中,我尝试保留onTouchListener,并且onClickListener我也在requestFocus的位置,但这似乎不起作用.
row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recentrowLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_left_5"
android:clickable="true"
tools:ignore="UseCompoundDrawables,HardcodedText,ContentDescription,UselessParent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_bg"
android:padding="@dimen/margin_left_5" >
<RelativeLayout
android:id="@+id/rl1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/addSubscribe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
<TextView
android:id="@+id/flikart_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="FLIKART"
android:textColor="@color/gray"
android:textSize="@dimen/medium_text_size" />
<ImageView
android:id="@+id/addToFav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<LinearLayout
android:id="@+id/rl2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rl1"
android:layout_marginLeft="@dimen/margin_30" …Run Code Online (Sandbox Code Playgroud) 我的界面上有一个警报符号.我想要它,如果有人点击这个,那么他/她可以得到另一个界面.那么如何编写Imageview的点击事件.请给我答案.谢谢
我对Android中的动画很新.对于3D动画,我必须使用OpenGL使其看起来更流畅.
是否有可能转换Drawable为我在画布上绘制一些矩形或圆形,我想将其转换为View使用OpenGL.这是可能的,如果是这样,那怎么样?
任何人都可以让我知道FEATURES中的第一点在这个URL中说了什么http://developer.android.com/reference/android/opengl/GLSurfaceView.html
我被要求处理一个任务,其中将有两条线,我必须得到两条线的交点.两条线是ImageViews,两条线都ImageView可以被拖动,每当这两条线相交时,我必须得到那个交点.这是我到目前为止实现的代码:
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/xImg1" android:layout_width="100sp"
android:layout_height="100sp" android:layout_marginTop="50sp"
android:layout_marginLeft="10sp"
android:background="@drawable/line_6x10" />
<ImageView android:id="@+id/xImg2" android:layout_width="100sp"
android:layout_height="100sp" android:layout_marginTop="50sp"
android:background="@drawable/line_10x10" android:layout_marginLeft="200sp" />
Run Code Online (Sandbox Code Playgroud)
main.java
package sra.inter;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.RelativeLayout.LayoutParams;
public class Main extends Activity implements OnTouchListener {
private ImageView mImg1, mImg2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); …Run Code Online (Sandbox Code Playgroud) AIDL是否支持短型?
http://developer.android.com/guide/developing/tools/aidl.html
它说"Java编程语言中的所有原始类型(例如int,long,char,boolean等)"
但似乎不能在AIDL中使用short.
谢谢 !