今天早上我想出了一个试图处理这个onConfigurationChanged事件的问题.问题是当我改变手机的方向时,我覆盖的方法没有被调用.根本没有被召唤.
我已经android:configChanges="orientation"在android文档中提到了清单中定义的活动,但这没有什么区别.
你有没有想出这个问题?
有谁知道我如何设置自定义对话框的边距?我问,因为我有一个自定义对话框但是在显示时它会延伸以填充父对象,即使我在布局参数上明确设置了WRAP_CONTENT.
基本上,对话框包含一个listview,其元素必须向下滚动,当元素为1时,它不会拉伸,但是当添加更多项时,对话框占据整个屏幕.
有什么建议?我尝试了所有可能的解决方案组合而没有取得满意的结果
编辑:添加了对话框布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="50dip"
android:orientation="vertical"
android:layout_gravity="top|center">
<FrameLayout android:layout_width="fill_parent" android:layout_margin="5dip" android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="20sp" android:textColor="@color/black"/>
<Button android:layout_height="32dip" android:layout_width="32dip"
android:id="@+id/guide_dialog_cross_button"
android:background="@drawable/button_cross_white"/>
</FrameLayout>
<ListView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:fadingEdge="none"
android:layout_margin="5dip"/>
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_margin="5dip" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我遇到了同样的问题 - 正如谷歌开发者小组中所发现的那样.我引用Chris Grebeldinger(原作者)的非常详细的解释.
"在文档中:http: //developer.android.com/guide/topics/data/backup.html#Testing
它建议通过以下方式测试应用程序的备份/恢复:
一切似乎都很好,直到第4步,当我在日志中看到这个:
V/BackupManagerService(306):removePackageParticipantsLocked:uid = 10078#1 V/BackupManagerService(306):删除com.example.app的备份知识
然后是第5步:
V/BackupManagerService(306):restoreAtInstall pkg = com.example.app token = 21 V/BackupManagerService(306):没有恢复集 - 跳过恢复
因此,当卸载应用程序时,显然备份的数据会被破坏,这意味着官方测试工作流程可能无法正常工作?测试这个的最佳方法是什么?"
有没有人设法运行并正确测试此样本?
我有一个问题,也许是一个愚蠢的问题,但我认为这很重要.
为什么参数:convertView(View)就可以了
public View getView(int position, View convertView, ViewGroup parent)
总是空的?android应该在第一次创建后回收视图,不是吗?或者我该如何回收这些观点?
我觉得这个方法接收了这三个参数,但在任何谷歌示例中都没有使用它们中的任何一个.
我遇到了一个问题.我需要在图库中突出显示所选项目.我试过通过这种方法改变所选视图的外观:
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
Run Code Online (Sandbox Code Playgroud)
该视图的第二个参数是当前选定的视图,我正在尝试在这种情况下,增加文本的大小.但是这不起作用,即使我在所选项目或整个图库中调用invalidate也不行.
这是我用来更改textview文本大小的代码
TextView textview = (TextView)view;
textview.setTextSize(50, TypedValue.COMPLEX_UNIT_SP);
textview.invalidate();
Run Code Online (Sandbox Code Playgroud)
你知道怎么做吗?谢谢