我正在尝试将setStyle扩展到我的自定义对话框,该对话框扩展了dialogFragment,构造函数如下所示:
MyCustomDialog() {
super();
setStyle(STYLE_NO_FRAME, 0);
}
Run Code Online (Sandbox Code Playgroud)
我仍然看到我的布局周围的框架.
有没有人有任何想法?
我有一个通常是的ListView singleChoice
choiceMode
.当用户长按项目时,我想进入允许选择多个项目的动作模式,以便他们可以对任何选定的项目执行操作.
我能够配置它ListView
以使其处于singleChoice
模式,并且用户能够选择列表项以在其旁边显示细节片段并使列表项本身显示为其激活状态.
我也能够配置它ListView
以便multipleChoiceModal
choiceMode
在项目中执行长按并启动动作模式并允许多个选择,但现在ListView将不允许在正常模式下进行单个选择(无动作模式).
如何处理singleChoice
模式中的ListView,然后multipleChoiceModal
在长按项目时将其转换为模式?
这是我能够提出的最接近的:
singleChoice
模式OnItemLongClickListener
并在该侦听器中:
OnItemLongClickListener
为null
choiceMode
为multipleChoiceModal
view.performClick()
长按的项目.这种方法有几个问题.
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
,onDestroyActionMode
我得到一个java.lang.StackOverflowError
因为该方法最终也试图破坏动作模式(但我们还没有从破坏中返回).android android-3.0-honeycomb android-4.0-ice-cream-sandwich
我正在研究一个试图通过DexClassLoader加载外部库的项目.这在2.3中非常有效:
public class FormularDisplayLoader {
public final static String PATH ="/data/data/at.mSystem.client/files/mSystem_Client_FormularLibrary.jar";
private DexClassLoader classLoader;
public FormularDisplayLoader(Context context){
this.context = context;
this.classLoader = new DexClassLoader("/data/data/at.mSystem.client/
files/mSystem_Client_FormularLibrary.jar",
context.getFilesDir().getAbsolutePath(),
null,
FormularDisplayLoader.class.getClassLoader());
}
public View getDisplay(String className) throws ErrorCodeException{
try {
Class c = classLoader.loadClass(className);
Method m = c.getMethod("getDisplay", Context.class);
View ret = (View) m.invoke(c.newInstance(), context);
return ret;
} catch (Exception e) {
e.printStackTrace();
throw new
ErrorCodeException(FormularErrorCode.NO_DISPLAY_AVAILABLE_FOR_FORMULAR);
}
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,当尝试将此应用程序移植到Honeycomb时(因为此应用程序的实际目标是平板电脑),DexClassLoader会抛出异常:
02-23 09:30:58.221: ERROR/dalvikvm(8022): Can't open dex cache '/data/
dalvik-cache/
data@d...@at.mSystem.client@files@mSystem_Client_FormularLibrary....@classes.dex':
No such file …
Run Code Online (Sandbox Code Playgroud) 我在平板电脑应用程序中有一个活动,我想根据方向显示不同的碎片.我认为最简单的方法就是定义两个不同的布局XML文件,一个用于横向,一个用于纵向.换句话说,我有/layout/home.xml,如下所示:
<LinearLayout android:orientation="horizontal">
<fragment class="com.foo.app.Frag1" android:id="frag1"/>
<fragment class="com.foo.app.Frag2" android:id="frag2"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
然后在/layout-port/home.xml中:
<LinearLayout android:orientation="vertical">
<fragment class="com.foo.app.Frag2" android:id="frag2"/>
<fragment class="com.foo.app.Frag3" android:id="frag3"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当我跑步时,我可以从风景开始去画像,一切都很好.但是,当我从纵向转到横向时,应用程序崩溃时会发生android.content.res.Resources $ NotFoundException,其资源ID等于"frag3".这是正确的,它正在寻找Frag3时,去景观制作,并在该模式中没有Frag3.这在Activity.onCreate堆栈期间发生,因此在我的任何代码有任何机会使应用程序崩溃之前.
片段不应该以这种方式工作吗?我需要使用FragmentTransaction吗?
我想让我的应用程序向后兼容,所以我需要显示菜单按钮,因为我们在以前版本的应用程序中使用了菜单按钮.
所以我正在阅读并且它说如果你的目标是11(3.0)而不是你没有得到菜单按钮,但它你的目标是10你做的.
但问题是我使用碎片所以我的目标必须是11.
有什么想法吗.
我正在制作一个与1.6+兼容的蜂窝项目/前叉.
基于Google/Android提供的文档,我决定将我的所有片段构建起来,这些片段DialogFragment
非常适合蜂窝...它使我可以灵活地将任何内容作为对话框或"全屏"元素.
我现在已经整合了兼容工具包,并将我的导入和方法调用移到了那里.现在我在2.3我试图发起一个相同的意图,但我收到这个问题:
java.lang.IllegalStateException: DialogFragment can not be attached to a container view
Run Code Online (Sandbox Code Playgroud)
该文档DialogFragment
表明它可以Fragment
在您不需要对话框/弹出功能时执行.
android android-layout android-fragments android-3.0-honeycomb
我有一个在后台下载文件的持续通知.我已经成功创建了多个同时更新进度条通知,这些通知也可以取消.这适用于所有经过测试的设备,除了一些最近使用Honeycomb的Android平板电脑.
现在的效果是原始通知消息不断被重新显示,从而阻止用户点击时钟以显示正在进行的通知列表.因此,甚至没有看到进度条.有没有人成功地在Honeycomb上创建进度条通知?
作为一方,我还发现我的黑色通知文本不再具有通知列表的黑色背景.有没有办法为Honeycomb设备设置白色文本?
注意:这已经在运行Android 3.0.1和Motorola Xoom的Optimus Pad L-06C上进行了测试
以下是通知创建
// Create new notification for downloading
mNotification = new Notification(R.drawable.owl_icon, getNotificationText(R.string.notification_content_downloading), 0);
mNotification.flags |= (Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT);
// Create custom progress bar view
RemoteViews contentView = new RemoteViews(CourseSyncService.this.getPackageName(), R.layout.notification_downloading);
contentView.setTextViewText(R.id.notificationTitle, mCourseTitle);
contentView.setProgressBar(R.id.notificationProgressBar, 100, 0, false);
contentView.setTextViewText(R.id.notificationPercentage, "0%");
mNotification.contentView = contentView;
// Create pending intent for the notification
Intent notificationIntent = new Intent(CourseSyncService.this, CancelDownloadActivity.class);
notificationIntent.putExtra(CourseSyncService.KEY_USER_ID, mUserId);
notificationIntent.putExtra(CourseSyncService.KEY_COURSE_ID, mCourseId);
notificationIntent.putExtra(CourseSyncService.KEY_COURSE_TITLE, mCourseTitle);
PendingIntent contentIntent = PendingIntent.getActivity(CourseSyncService.this, mCourseId, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
mNotification.contentIntent = contentIntent;
// …
Run Code Online (Sandbox Code Playgroud) 我创建了一个示例应用来测试这个重叠的问题.
我有一个片段类型Fragment1,我创建了一个Fragment1的新实例,并在运行时将它添加到我的活动中的FrameLayout.我在几个按钮的帮助下添加片段.
注意:我已经为Fragment1的每个新实例提供了一个不同的数字(#1,#2,#3等),以便在UI上显示,以帮助我找出我正在查看的片段.
所以..这就是我做的:
现在,我有这样的片段:1(#1),2(#2),1(#3),2(#4),1(#5),2(#6).
我在查看片段#6时按后退键.
似乎片段在彼此的顶部显示.
为什么?有重叠的问题吗?如何清除这个重叠的问题.我认为这将是兼容性库的一个问题...但它也是3.0.
添加片段的代码:
public int doFragmentChange(int cont1, Fragment frag1, String tag1, int cont2, Fragment frag2, String tag2,
boolean addToStack, String stackTag) {
FragmentManager fm = getFragmentManager();// getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
if (frag1 != null) {
ft.replace(cont1, frag1, tag1);
}
if (frag2 != null) {
ft.replace(cont2, frag2, tag2);
}
// add fragment to stack
if (addToStack)
ft.addToBackStack(stackTag);
return ft.commit();
}
Run Code Online (Sandbox Code Playgroud) 我有一个自定义的EditText,需要自定义"粘贴".
我重写onTextContextMenuItem(int id)来处理通过选择上下文菜单请求的"粘贴".
@Override
public boolean onTextContextMenuItem(int id) {
switch(id){
case android.R.id.paste:
doMyPaste();
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
这适用于3.0之前的Android.
但是,在3.0中,如果长按按钮,或者点击光标,则在光标小部件附近会有一个小的"粘贴"小部件.
当用户从此窗口小部件"粘贴"时,onTextContextMenuItem(int id)
将不会调用该窗口小部件.结果,我不能做自定义粘贴.
有谁知道那个小的"粘贴"小部件是什么?我应该用哪种方法覆盖自己的"粘贴"?
android paste textview android-edittext android-3.0-honeycomb
因此,我今天刚收到第四封电子邮件,内容是关于支持最新版本的平板电脑,其中一个10英寸的屏幕,分辨率为1920 x 1200像素.我的应用程序中的布局是针对每种设备类型的最佳选择而定制的,但是我不可能以1920 x 1200像素分辨率启动SDK模拟器,因此我无法进行布局这个屏幕尺寸.
我已经多次向Android开发者团队提及他们每周的Google+视频群聊问题(并且他们并不在乎),我在Stack Overflow和网络上看到了很多关于它的其他问题我也是还向Android Tools网站提出了有关此问题的两个错误.我仍然留下一个不能在这些高分辨率下工作的模拟器.
市场上有一些具有这些高分辨率的设备,我知道Android操作系统支持它,所以我被模拟器的极限所困扰.
我的电脑是一款功能强大的电脑,可以运行它,以前从未出现过低分辨率仿真器的问题.如果有人能帮助我,我会非常高兴,因为这让我疯狂.
android android-3.0-honeycomb android-4.0-ice-cream-sandwich
android ×10
android-4.0-ice-cream-sandwich ×2
button ×1
dialog ×1
fragment ×1
menu ×1
paste ×1
progress-bar ×1
target ×1
textview ×1