我slidingDrawer在我的应用程序中使用a ,在纵向模式下将其处理程序放在底部.当用户切换到横向模式(宽屏)时,我希望处理程序位于左侧.当我将方向从垂直方向更改为水平方向时,处理程序位于右侧.
我已经像这样定义了我的布局XML:
<SlidingDrawer
android:id="@+id/l_drawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:handle="@+id/l_handle"
android:content="@+id/l_content"
android:orientation="horizontal"
android:layout_gravity="left"
>
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何让它从左向右滑动?
我有一个非常简单的应用程序,一个ImageView和一个Button.我的ImageView加载的第一个Drawable资源在XML Layout中使用"android:src"标记指定,但是在运行时我想要更改它显示的图片.为此,我启动一个活动结果从SD卡中选择一个图像(意图发送到MediaStore.Images.Media.EXTERNAL_CONTENT_URI).但是,当选择图片时,我尝试使用所选图片的URI更新ImageView,但我收到消息" java.lang.OutOfMemoryError:位图大小超过VM预算 "
我试图用我的HTC-Hero加载用相机拍摄的照片(照片大小约为1.1M),但没有成功,似乎只适用于小于500KB的照片.但是我需要加载用相机拍摄的照片.我怎么解决这个问题?我究竟做错了什么.在我看来,代码非常简单,应该可以工作.
public void onClick(View v){
Intent selectImageIntent=new Intent(Intent.ACTION_PICK ,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(selectImageIntent,1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==Activity.RESULT_OK){
Uri selectedImageUri = data.getData();
Log.i(TAG,"chosen image: "+selectedImageUri.toString());
ImageView imageView = (ImageView) this.findViewById(R.id.ImageView01);
imageView.setImageURI(selectedImageUri);//here I get the OutOfMemoryError
imageView.invalidate();
}else{
//canceled
}
}
Run Code Online (Sandbox Code Playgroud)
ps这是应用程序应该做的唯一事情,我不是在创建其他对象,所以我想指出除了显示图像之外我不会将堆空间用于其他东西.
MultiAutoCompleteTextView当我输入几个字母时,我正在做一个简单的程序来提示常用词.
码:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_dropdown_item_1line,
ary);
MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.editText);
textView.setAdapter(adapter);
textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
private String[] ary = new String[] {
"abc",
"abcd",
"abcde",
"abcdef",
"abcdefg",
"hij",
"hijk",
"hijkl",
"hijklm",
"hijklmn",
};
Run Code Online (Sandbox Code Playgroud)
现在,当我输入'a'并选择"abcd"但结果变为"abcd"时.如何用空格替换逗号?
谢谢!
我有一个WidgetProvider和一个Configure Activity
当Widget启动时,它从configure活动开始,我通过对widgetprovider进行自定义调用来设置它
(你会注意到来自sdk教程的例子)
// Push widget update to surface with newly set prefix
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
AwarenessWidget.updateAppWidget(context, appWidgetManager,
mAppWidgetId, position);
// Make sure we pass back the original appWidgetId
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, resultValue);
finish();
Run Code Online (Sandbox Code Playgroud)
我将Widget ID传递给函数....在widget中我创建了一个Intent,如下所示:
Intent configIntent = new Intent(context, Configure.class);
configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
PendingIntent pendingIntent = PendingIntent.getActivity
(context, 0, configIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.MainImage,pendingIntent);
views.setImageViewResource(R.id.MainImage, lv_images[version]);
appWidgetManager.updateAppWidget(appWidgetId, views);
Run Code Online (Sandbox Code Playgroud)
我总是引用窗口小部件ID,甚至将其添加为意图的额外内容,但是当我在主屏幕上获得其中两个小部件时,窗口小部件ID始终引用最后放置的窗口小部件ID
我想弄清楚如何在我的小部件上禁用更新周期?我不需要这个特殊功能.添加它的时候我调用onUpdate的小部件就好了......
我有一个2.1及以上的工作应用程序,直到我尝试用主题样式清理我的初始布局.现在,应用程序甚至不会以"您必须提供layout_height属性"失败消息开始,该消息指向布局中的第一个EditText视图.
为什么我不能将每个EditText上正常工作的'layout_height = 30dp'移动到... item name ="android:layout_height"> 30dp <...以我的主题引用的样式?
事实上,我抽象出来的所有其他风格效果都很好.
[我不会惊讶地发现,必须对LinearLayout进行一些样式覆盖,而不是EditText.或者它必须是View的样式项,而不是Widget.不知道]
想法?任何人?什么是被忽视的显而易见的事情?在此先感谢您的任何建议!
AndroidManifest.xml中:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<application android:label="xxx"
android:icon="@drawable/xxx" >
<activity android:name="DataEntry"
android:label="xxx"
android:theme="@style/xxx_theme.A" >
...
Run Code Online (Sandbox Code Playgroud)
xxx_theme.A.xml
<style name="xxx_theme" parent="@android:Theme" >
<item name="android:windowNoTitle">true</item>
</style>
<style name="xxx_theme.A" >
<item name="android:textViewStyle">@style/xxx_TextView_widget</item>
<item name="android:editTextStyle">@style/xxx_EditText_widget</item>
<item name="android:checkboxStyle">@style/xxx_CheckBox_widget</item>
<item name="android:radioButtonStyle">@style/xxx_Radio_widget</item>
</style>
<style name="xxx_EditText_widget" parent="@android:style/Widget.EditText" >
<item name="android:textSize">9dp</item>
<item name="android:layout_height">30dp</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingTop">1dp</item>
<item name="android:paddingBottom">1dp</item>
<item name="android:textColorHint">@color/texthint</item>
<item name="android:singleLine">true</item>
<item name="android:selectAllOnFocus">true</item>
<item name="android:inputType">textNoSuggestions</item>
</style>
...
Run Code Online (Sandbox Code Playgroud) 我在我的Android应用程序中有一个webview,但是当有人在网站上导航时,它会在新窗口中打开,我希望它保留在webview中..有没有办法轻松地做到这一点?这是我活动中的代码:
super.onCreate(savedInstanceState);
setContentView(R.layout.shop);
WebView webview;
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://www.google.co.uk");
Run Code Online (Sandbox Code Playgroud) CardView除了阴影或高度之外,有什么优点和缺点,性能和外观有什么好处?使用的内容CardView也可以使用其他布局的组合来完成.
performance android android-widget android-layout android-cardview