我有一个工作的平板电脑应用程序,我现在也试图在手机上工作.在表格上,屏幕上有两个片段,一个列表片段和一个细节片段.当在电话上时,列表片段出现并在按下列表项时创建新活动.此活动只是在onCreate()方法中创建片段并将其提交到屏幕,如下所示.
// Place an DeallDetailsFragment as our content pane
DealDetailsFragment f = new DealDetailsFragment();
getFragmentManager().beginTransaction().add(android.R.id.content, f).commit();
getFragmentManager().executePendingTransactions();
Run Code Online (Sandbox Code Playgroud)
这是按预期工作的,但是从这个活动中我需要告诉片段要加载和显示的细节.在我的DealDetailsFragment类中,我有一个updateDeal()更新内容的方法,如下所示.
if (deal==null) { // could be null if user presses the loading deals list item before it loads
return;
}
this.deal=deal;
if (dealTitle==null) { // get the view objects only once
holder = new ViewHolder();
holder.dealHeat=(TextView) getView().findViewById(R.id.dealDetails_heat_textView);
holder.dealPrice=(TextView) getView().findViewById(R.id.dealDetails_price_textView);
holder.dealRetailer=(TextView) getView().findViewById(R.id.dealDetails_retailer_textView);
holder.dealTitle=(TextView) getView().findViewById(R.id.dealDetails_title_textView);
holder.dealDesc=(TextView) getView().findViewById(R.id.dealDetails_desc_textView);
holder.goToButton= (LinearLayout) getView().findViewById(R.id.dealDetails_goToDeal);
holder.dealImage=(ImageView) getView().findViewById(R.id.dealDetails_imageView);
holder.postedBy=(TextView) getView().findViewById(R.id.dealDetails_poster_textView);
holder.datePosted=(TextView) getView().findViewById(R.id.dealDetails_date_textView);
Run Code Online (Sandbox Code Playgroud)
getView() 当应用程序在只显示单个片段的手机上运行时返回null.
有任何想法吗?不幸的是,网上没有很多片段示例.
android android-intent android-layout android-fragments android-4.0-ice-cream-sandwich
我一直在搜索互联网(例如Android文档,这里的答案等),以获得我认为是一个相当微不足道的问题的答案.您如何实现像Google音乐和YouTube中的半透明操作栏(链接是图像示例)?
我希望视频内容是全屏的,不受操作栏的约束/推送,同时仍然利用内置UI组件的优势.我显然可以使用完全自定义的视图,但如果可能的话,我宁愿利用ActionBar.
表现
<activity
android:name="videoplayer"
android:theme="@android:style/Theme.Holo"
android:launchMode="singleTop"
android:configChanges="keyboardHidden|orientation"/>
Run Code Online (Sandbox Code Playgroud)
活动
// Setup action bar
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
View customActionBarView = getLayoutInflater().inflate(R.layout.player_custom_action_bar, null);
actionBar.setCustomView(customActionBarView,
new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
R.dimen.action_bar_height));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
Run Code Online (Sandbox Code Playgroud)
菜单
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/button1"
android:icon="@drawable/button1"
android:showAsAction="always"/>
<item
android:id="@+id/button2"
android:icon="@drawable/button2"
android:showAsAction="always"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
自定义ActionBar视图
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:background="@color/TranslucentBlack">
<!--Home icon with arrow-->
<ImageView
android:id="@+id/home"
android:src="@drawable/home"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<!--Another image-->
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:visibility="visible"/>
<!--Text if no image-->
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:visibility="gone"/>
<!--Title--> …Run Code Online (Sandbox Code Playgroud) android android-3.0-honeycomb android-4.0-ice-cream-sandwich android-actionbar android-5.0-lollipop
如何禁用/隐藏没有菜单按钮的ICS手机上的三点指示器(选项菜单指示器).?
我<uses-sdk android:minSdkVersion="5"/>在Manifest中运行应用程序,编译代码4.0.每个屏幕上都会显示三点指示符.
偏好活动的示例我不希望显示三点指示符,因为它没有任何菜单选项.
添加android:targetSdkVersion="14"清单可行.但是,不希望在所有屏幕上隐藏/删除三个点按钮.仅在首选项活动中不希望显示此三个点按钮.
我试图检查Android导航栏是否存在加载,以便我可以相应地调整布局,有没有人有任何建议?
这是我试图检测的导航栏:

PS我到目前为止所发现的都是'糟糕'的方法来尝试删除吧,我不想这样做.
java layout android android-4.0-ice-cream-sandwich android-4.2-jelly-bean
我正在做我的第一个Android应用程序,并希望直接进入ICS API.到目前为止,我已经使用ActionBar创建了一个应用程序,使用Viewpager和Fragments可以使用可滑动的选项卡.
然而,我确实经历了一些我一直在回归的错误.
根据我如何实现它,它总是回到"类型不匹配"错误:"无法从android.support.v4.app.Fragment转换为android.app.Fragment".我已经尝试删除所有导入引用,当我在TabListener,FragmentActivity和我的两个片段中仅使用android.support.v4.app.Fragment时出现此错误.
我的TabListener中发生错误:
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.util.Log;
public class TabListener implements ActionBar.TabListener {
private android.app.Fragment fragment;
private Activity activity;
private ViewPager pager;
private FragmentTransaction ft;
public TabListener(Activity activity, Fragment fragment, ViewPager pager) {
this.activity = activity;
this.fragment = fragment;
this.pager = pager;
}
@Override
public void onTabSelected(Tab tab, android.app.FragmentTransaction ft){
if (fragment == null) {
ft.add(fragment, null);
} else {
ft.attach(fragment);
}
}
@Override
public void onTabReselected(Tab tab, …Run Code Online (Sandbox Code Playgroud) java android android-fragments android-viewpager android-4.0-ice-cream-sandwich
在运行Android 4.0(Ice Cream Sandwich)的Android模拟器上测试时,我注意到Edittext做了一些非常奇怪的事情.
首先,它强调了用红色标识为"拼写错误"的每个单词.如何禁用此功能?其次,尽管在布局XML中我指定了android:scrollHorizontally="true"自动换行:如何禁用它?以下是Edittext的Layout XML代码:
<EditText
android:id="@+id/editor"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_below="@+id/toolbar"
android:layout_toRightOf="@+id/toolbarleft"
android:paddingBottom="0dp"
android:paddingRight="0dp"
android:scrollHorizontally="true"
android:text=""
android:inputType="textMultiLine" >
<requestFocus />
</Edittext>
Run Code Online (Sandbox Code Playgroud)
以下是我需要禁用的拼写检查器的示例:
拼写检查器的演示http://www.abstract-thoughts.com/wp-content/uploads/2011/10/spell.jpg
非常感谢!
android spell-checking word-wrap android-edittext android-4.0-ice-cream-sandwich
冰淇淋三明治(Android 4.0)增加了Action Bar在手机上屏幕底部的选项,这是我喜欢在我的应用程序中使用的东西.该文件提到uiOptions="splitActionBarWhenNarrow"的,当你想要的东西,也就是选项卡,在顶部和Action Bar快捷键在底部.我已经尝试在应用程序清单中添加该行,如文档中所述,但到目前为止尚未使用它.
这是一个例子:

此外,我注意到在运行ICS的Galaxy Nexus上,消息传递应用程序Action Bar的底部只有顶部的标题,因此必须以某种方式强制Action Bar它位于底部.
有任何想法吗?
我有一个WebView(Android 3.0+)的问题,WebView在显示我的黑色背景("闪烁")之前总是显示白色背景.这是我简单的测试代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView = new WebView(this);
webView.setBackgroundColor(Color.BLACK);
setContentView(webView);
loadWebView(webView);
webView.loadDataWithBaseURL("localhost://", "<html><head>" +
"<style>body {background-color: #000}img{max-width:100%}</style></head>" +
"<body>" +
"<img src=\"http://developer.android.com/images/practices/actionbar-phone-splitaction.png\" />" +
"</body></html>",
"text/html", "UTF-8", null);
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多解决方案来摆脱这个问题,但并不幸运.
PS:如果关闭硬件加速,则不会出现此问题.有人有同样的问题并解决了吗?
谢谢.
android webview hardware-acceleration android-3.0-honeycomb android-4.0-ice-cream-sandwich
我已经有这个问题差不多2个月了,无法解决这个问题.问题是如果我的应用程序正在运行并且我从Eclipse运行(重新安装)我的应用程序,我会收到一条错误消息,指出我的应用程序崩溃了"不幸的是,已经停止了.".我注意到当我从PC/Eclipse运行它时也会发生这种情况,我认为只有在我暂时不运行它之后才会发生这种情况.
只有当应用程序在第3个activity(BaseDiagramActivity)中处于活动状态然后我再次从Eclipse运行应用程序时才会发生这种情况.除了3个活动之外,我基本上已经删除了所有应用程序,而且它仍在发生.
我搜索并搜索了这个问题的解决方案,但找不到任何好的答案或适用于我的答案.
它似乎不是硬件或Android版本问题因为我在我的平板电脑(4.0.3)和我的手机(4.0.2,在更新前发生在4.0.1上)运行它.除非当然是冰淇淋夹心虫.
如果需要更多信息,请告诉我.
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
at android.app.ActivityThread.access$1300(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
... 11 more
Run Code Online (Sandbox Code Playgroud)
LoadedApk.initializeJavaContextClassLoader() - 362行似乎是罪犯
以下是相关文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="[my package]"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" …Run Code Online (Sandbox Code Playgroud) eclipse android android-intent android-4.0-ice-cream-sandwich
我已经搜索过片段的寻呼机,我在ICS API上开发.
我知道ViewPager和早期版本的所有支持库,但我不明白为什么我应该使用支持库考虑我使用最新版本的api并且不打算支持早期版本的事实.
我是否必须自己编写"ViewPager"或者是否有我在api中看不到的内容.