I'm trying to do something similar to iOS editable UITableView. I have a list of "added items" if the user clicks on "Add new item" he is taken to a PreferenceScreen with multiple <Preference> elements, onclick the should disappear from this screen and add it to the "Added list" (actually a <PreferenceCategory>), then they should be able to remove them from here or edit their order. This is similar to iOS editable lists.
This is my XML:
<PreferenceScreen android:title="ALL APPS" android:key="app_list">
<!-- A <preference> for each app -->
</PreferenceScreen>
<PreferenceCategory android:title="ADDED APPS" android:key="my_apps_list">
</PreferenceCategory>
I have tried uncountable times and I cannot get it to work.
How can I get it done?
I've experimented around a bit and it's actually very easy when you nest your PreferenceScreens.
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference android:title="Check it!" />
<PreferenceScreen android:title="To the other preferences!" android:summary="I really hope this works <3" >
<EditTextPreference android:title="Edit your name" android:summary="Edit your name :)" />
<CheckBoxPreference android:title="Accept answer" />
</PreferenceScreen>
</PreferenceScreen>
PS: Please excuse my hard-coded string literals - it was just for testing! :)
this looks like a very similar question to what i've asked in the past:
android - showing listView in PreferenceActivity
when selecting the items to show , store them in some way (DB ,references ,etc...) and then use the solution i've found .
as you can see , the view used in preference activity is actually a listView , so it's weird to put a listView in a listView . what you need is a special trick , and that's something i've written about .
Please have a look to the accepted answer on this question:
How to remove Android preferences from the screen
Sometimes, if categories are present, you have to
"reference the category containing the preference you wanted to remove and then remove that preference from that category"
like the answer there says. Isn't this also your case?
Hope this helped.
Related
I’m having a hard time figuring out why my App Widget ListView won’t populate with data. Everything seems to be wired up right. When I debug, I can see the data that is being retrieved from my database (Firestore). However, it still won’t populate into the App Widget.
I created a new Issue on my Github to make it easier to view the problem:Github Issue
RemoteViewsFactory
The data is successfully retrieved from Firestore DB
List<Review> reviews is populated
The Review objects within it contain the right data
get() methods return the right data
ReviewsAppWidgetProvider
ReviewsWidgetService Intent is created
setRemoteAdapter() is called using the Intent and passing in the ListView as well
updateAppWidget() is called
notifyAppWIdgetViewDataChaged() is called
ReviewFragment
ReviewsAppWidgetProvider.updateAppWidgets() is called when adding or deleting reviews
AndroidManifest
ReviewsAppWidgetProvider declared as a reveiver
Intent Filter set for action.APPWIDGET_UPDATE
ReviewsWidgetService declared as Service
permssion BIND_REMOTEVIEWS set
As you said, everything is ok with fetching data. But it's still draw a loading view. So the problem is in your divider. View can't be used in app widgets, because launcher process doesn't know about view, it's only know about limited count of views, all views that can be used, you can find here.
So how to make a such divider?
Firstly you need a shape, so it will be something like bottom_border.xml:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="0.5dp"
android:color="#CCCCCC" />
</shape>
So now in your root view add background bottom_border.xml like:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#drawable/bottom_border"
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
I need my widget to interact with any built-int browser. What I mean by an interaction is to know the content of the visible web page. Is it possible for a floating widget to "know" what DOM element lies below and read some info about the element? The following scenario is demanded: user moves the widget across a browser with some HTML page visible, the widget then recognizes HTML elements and shows the user some information about that element.
If there is no such possibility, is it possible to read the whole text from the actual web page? Only text, without any other objects.
if you want to show a web page directly on your app, you can use android webview. Make a activity with a webview.
webveiw.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
then you can use in the activity
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.example.com");
you have to add this part in your manfiest file
<manifest ... >
<uses-permission android:name="android.permission.INTERNET" />
...
</manifest>
Use this guide
http://developer.android.com/guide/webapps/webview.html
I am getting the error: error: No resource identifier found for attribute 'showAsAction' in package:
I cannot find out why I am getting this error but I have been at it for hours without any sort of break through. I have searched google with many different resolutions but none that appear to work for me.
I would be grateful if someone could help direct me towards a fix to the error.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.nibbler.zoe.liteplayer.MainActivity" >
<item
android:id="#+id/action_settings"
android:orderInCategory="100"
android:title="#string/action_settings"
app:showAsAction="never"/>
</menu>
Most likely showAsAction is not your attribute, hence not available in app: namespace. Did you mean android:showAsAction?
If u are having min ver below 14 and u want to add showAsAction for below 14 api devices, then u can use this.
1.)U need support library to be added in build path.
2.)Need to add app theme as Theme.appcompat.
3)Rest are as u are using means add ur own namespace with .../res-auto value and use that name with showAsAction
You can add support lib res like this http://developer.android.com/tools/support-library/setup.html
You need to extends ActionBarActivity instead of Activity.
For complete Action bar guide follow the link http://developer.android.com/training/basics/actionbar/setting-up.html
I have a preference screen containing a preferenceList. i want the user to be able to add new friends to that list.
I have been unable to find any examples of how i can achieve such a thing doing run time.
Does anyone have an example or able to give me an example of how i would achieve this?
Here is my preference:
<PreferenceCategory android:title="Your competetion">
<PreferenceScreen
android:key="secondPrefScreen"
android:summary="click here to see your friends"
android:title="Friends" >
<ListPreference
android:key="friendList"
/>
</PreferenceScreen>
You can access the ListPreference object at runtime and use the setter and getter methods to update the entries. ListPreference Docs
Assuming you are inside a PreferenceActivity:
PreferenceScreen root = this.getPreferenceScreen();
ListPreference list = (ListPreference) root.findPreference("secondPrefScreen");
// do stuff with list
Here's my code:
<PreferenceCategory
android:summary="Fade information"
android:title="Fade Effects">
<CheckBoxPreference
android:title="Fade In/Out"
android:defaultValue="false"
android:key="fadeIn"/>
<CheckBoxPreference
android:title="Heartbeat"
android:defaultValue="false"
android:key="heartbeat" />
<CheckBoxPreference
android:title="Pulse"
android:defaultValue="false"
android:key="pulse" />
<CheckBoxPreference
android:title="None"
android:defaultValue="true"
android:key="none" />
</PreferenceCategory>
I'm basically trying to figure out how to make those CheckBoxes appear as they are, but having them unclickable by the user.
Using android:enabled="false" is incorrect as this actually completely disables a View (it also greys it out which is the main issue). What you want to do instead is:
android:clickable="false"
This simply stops the user clicking the View but doesn't officially 'disable' it. I think that's more what you are looking for.
Use android:enabled="false" from your XML, or setEnabled() in Java code.
You can use android:selectable="false" in xml if you don't wish to gray out the CheckboxPreference.