我有一个工作的平板电脑应用程序,我现在也试图在手机上工作.在表格上,屏幕上有两个片段,一个列表片段和一个细节片段.当在电话上时,列表片段出现并在按下列表项时创建新活动.此活动只是在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
我目前的应用程序设置ListFragment在左侧和DetailsFragment右侧(类似于下面平板电脑上的布局).

在操作栏上,我有一个搜索小部件,当提交搜索词时,应该更新列表的内容(在ListFragment中).我一直在关注Android开发(搜索指南http://developer.android.com/guide/topics/search/search-dialog.html),但我有,让搜索更新相同的活动列表中的问题.
我已经设法通过在提交搜索词时调用新活动来实现某种形式的实现,但是这使得后退按钮表现得很奇怪(即,您按回去,然后转到上一个活动,搜索小部件仍然显示搜索词).
我已将意图行添加到清单中,如下所示
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
Run Code Online (Sandbox Code Playgroud)
是否有可能让搜索小部件更新当前活动的列表?
android android-searchmanager android-3.0-honeycomb android-4.0-ice-cream-sandwich android-actionbar
我目前正在开发一个Android应用程序,它从提供JSON数据的API获取数据.我将JSON数据的项目存储为字符串,导致出现一些奇怪的字符(例如'Â').我理解这与字符集有关,因此我将InputStreamReader设置为"UTF-8",但它似乎没有解决问题.
URL hukd = new URL(requestUrl);
URLConnection tc = hukd.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(tc.getInputStream(), "UTF-8"));
String line = in.readLine();
Log.d("line :", line);
JSONObject obj = new JSONObject(line);
JSONArray ja = obj.getJSONObject("deals").getJSONArray("items");
for (int i = 0; i < ja.length(); i++) { // each deal
JSONObject jo = (JSONObject) ja.get(i);
// make the deal
Deal d = new Deal(jo.getString("title"),
jo.getString("description"),
jo.getString("price"),jo.getString("temperature"),
jo.getJSONObject("merchant").getString("name"),
jo.getString("deal_image"),
jo.getString("deal_image_highres"));
listItems.add(d);
Log.d("Deal:", d.toString());
}
Run Code Online (Sandbox Code Playgroud)
Log.d"line"给出
01-30 19:56:01.909: D/line :(610): {"deals":{"items":[{"title":"Absolute steal ** Harmony one remote …Run Code Online (Sandbox Code Playgroud) 我最近升级了我的应用程序以使用ActionBarSherlock 4.1.由于在动作栏上设置自定义视图时,在Honeycomb上运行应用程序的升级用户会因为空指针异常而关闭力.
我将包含两个微调器的自定义视图添加到操作栏,这适用于Android 4.0和4.1,但不适用于3.2.
bar.setCustomView(R.layout.custom_action_bar);// spinners
actionBarViewHolder= new CustomActionBarViewHolder();
actionBarViewHolder.categorySpinner = (Spinner) findViewById(R.id.actionbar_catergory);
actionBarViewHolder.sortBySpinner = (Spinner) findViewById(R.id.actionbar_sortby);
Run Code Online (Sandbox Code Playgroud)
在Android 3.2上,在4.0和4.1中找不到微调器,它们的视图被找到并且任何东西都能顺利运行.
我没有在3.0模拟器上尝试过该应用程序,但我仍然认为该问题仍然存在.
任何想法可能是什么问题?
<LinearLayout android:id="@+id/linearLayout1"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="0.5">
<TextView android:id="@+id/textView1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Category:" />
<Spinner android:id="@+id/actionbar_catergory"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:entries="@array/actionbar_spinner_catergory"
android:background="@drawable/spinner_background" />
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout1"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="0.5">
<TextView android:id="@+id/textView2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Sort By:" />
<Spinner android:id="@+id/actionbar_sortby"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:entries="@array/actionbar_spinner_sortby" android:background="@drawable/spinner_background" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
android android-3.0-honeycomb android-4.0-ice-cream-sandwich actionbarsherlock android-actionbar
我目前的应用程序设置ListFragment在左侧和DetailsFragment右侧(类似于下面平板电脑上的布局).

在细节片段(列表旁边的片段)上我有一个转到交易按钮,按下时应该用一个替换detailsFragment WebViewFragment.
我遇到的问题是,当尝试在webviewfragment中加载URL时,该WebView值为null.
WebViewFragment webViewFragment = new WebViewFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.deal_details_fragment, webViewFragment);
transaction.addToBackStack(null);
// Commit the transaction
transaction.commit();
// Set the url
if (webViewFragment.getWebView()==null)
Log.d("webviewfragment", "is null");
webViewFragment.getWebView().loadUrl("http://www.google.com");
Run Code Online (Sandbox Code Playgroud)
下面是我的主要布局,其中定义了原始的两个片段.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_activity_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<fragment
android:name="com.bencallis.dealpad.DealListFragment"
android:id="@+id/deal_list_fragment"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" >
<!-- Preview: layout=@layout/deal_list_fragment --> …Run Code Online (Sandbox Code Playgroud) android android-webview android-fragments android-3.0-honeycomb android-4.0-ice-cream-sandwich
我有一个应用程序,它针对不同的流程具有不同颜色的导航栏。某些导航栏具有浅色背景,并且需要黑色状态栏文本。其他人有一个较暗的导航栏,并需要白色的状态栏文本。
作为迁移到 iOS15 的一部分,我更新了一个正在开发的应用程序,以使用UINavigationBarAppearance导航栏样式的方法。除了状态栏颜色之外,我可以像以前一样设置所有内容的样式。
以前我一直使用barStyle导航栏上的属性来设置状态栏文本颜色。
navigationBar.barStyle = .black
Run Code Online (Sandbox Code Playgroud)
使用时这似乎不起作用 UINavigationBarAppearance。
旧的造型方法
override func viewDidLoad() {
super.viewDidLoad()
let navigationBar = navigationController?.navigationBar
// Style using old approach
navigationBar?.barTintColor = UIColor.purple
navigationBar?.titleTextAttributes = [.foregroundColor: UIColor.white]
// Use barStyle to set status bar text color to white
// This only work when using the old styling approach
navigationBar?.barStyle = .black
}
Run Code Online (Sandbox Code Playgroud)
新的造型方法
override func viewDidLoad() {
super.viewDidLoad()
let navigationBar = navigationController?.navigationBar
// Style nav bar using new …Run Code Online (Sandbox Code Playgroud) 我希望通过类别方法添加一个新IBInspectable属性(计算属性)UILabel.理想情况下,我希望在设置标签文本后设置此属性(通过setValue:forKey),因为此IBInspectable属性可能导致UILabels文本被更新,我们不希望UILabel稍后的文本替换它.查看文档时,没有提及nib/storyboard在Interface Builder中配置的属性的加载期间是否始终在用户定义的属性之前设置预定义的属性.
是否使用自定义属性添加到Interface Builder中的对象IBInspectable或保证在标准预定义对象属性/属性之后设置用户定义的运行时属性?
是否可以在UILabel上设置排除路径?Apple文档声明UILabel现在构建在TextKit上,但UILabel似乎没有公开textContainer属性.
我希望实现一个tableview单元格,其中包括多个标签和一个标签不应重叠的roux徽章(如下所示).

如果使用UILabel是不可能的,我怎么能让TextView像UILabel一样(没有滚动,选择等)并调整大小以适应它的内容?
在横向模式下使用我的应用程序时,我的应用程序的某些用户遇到了一个奇怪的问题.我正在使用actionbarsherlock并将导航模式设置为制表符(使用ActionBar.NAVIGATION_MODE_TABS).一些用户发现在以纵向方式启动应用程序然后旋转设备时,操作栏显示一个微调器列表而不是选项卡(这显然是预期的行为).问题是微调器是不可选择的.
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.addTab(bar.newTab().setText("Deals").setTabListener(this),false);
bar.addTab(bar.newTab().setText("Vouchers").setTabListener(this),false);
bar.addTab(bar.newTab().setText("Freebies").setTabListener(this),false);
Run Code Online (Sandbox Code Playgroud)
编辑 刚刚发现它与我的自定义主题有关.将主题更改为默认的Sherlock.Light可使微调器可选.自定义主题如下所示.
<!-- Variation on the Holo Light theme that styles the Action Bar -->
<style name="DealPadTheme" parent="Theme.Sherlock.Light.ForceOverflow">
<item name="android:selectableItemBackground">@drawable/ad_selectable_background</item>
<item name="actionBarItemBackground">@drawable/ad_selectable_background</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionBarStyle">@style/Widget.ActionBar</item>
<item name="actionBarStyle">@style/Widget.ActionBar</item>
<item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="android:actionDropDownStyle">@style/MySpinner</item>
<item name="actionDropDownStyle">@style/MySpinner</item>
<item name="android:activatedBackgroundIndicator">@drawable/selectable_list_item</item>
<item name="activatedBackgroundIndicator">@drawable/selectable_list_item</item>
<item name="android:listSelector">@style/MyListView</item>
</style>
<style name="MyListView" parent="@android:style/Widget.ListView">
<item name="android:listSelector">@drawable/list_arrow_selected_holo</item>
</style>
<!-- style for the tabs -->
<style name="MyActionBarTabStyle">
<item name="android:background">@drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item>
<item name="android:gravity">center_horizontal</item>
</style>
<style name="Widget.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:displayOptions">showHome|useLogo|showCustom</item>
<!-- removed …Run Code Online (Sandbox Code Playgroud) android android-layout android-theme actionbarsherlock android-actionbar
我目前在Play商店有一个平板电脑和智能手机运行Android 3.0+(http://tinyurl.com/cnejnjs)的应用程序.为了吸引更多用户,我正在考虑让应用程序在大量设备上运行.
我知道ActionBar Sherlock,这似乎几乎可以做我想要的一切.它没有提供的一件事是我在当前应用程序中使用的搜索小部件.
有没有办法在操作栏中有一个搜索框,它以与默认搜索小部件的工作方式类似的方式更新屏幕上的当前列表片段?
android android-layout android-4.0-ice-cream-sandwich actionbarsherlock android-actionbar
android ×7
android-4.0-ice-cream-sandwich ×5
ios ×3
inputstream ×1
iphone ×1
json ×1
nib ×1
objective-c ×1
storyboard ×1
swift ×1
textkit ×1
uikit ×1
uistatusbar ×1
uitableview ×1
utf-8 ×1