add item to the settings in android framework - android

i am working in android frameworks.i want to add an item to the existing settings in the android OS.can u plz tell me how to do this?

First read about PreferenceActivity. These group of classes handle user prefs.
Then depending on your task, do something like this.
In case you want to add a live wallpaper or an input method add android:settingsActivity in your Manifest. (Example : here)
Or follow this tutorial

Related

Segmented Control in Android

We all know segmented control that is IOS but not in android. So I have an application that need something like that. For example let suppose I have a list of students and teacher marks the student either absent or present. and on click of each option there is a service call . for this I am using a library which is as follows:
compile 'info.hoang8f:android-segmented:1.0.6'
As I told you I have a list of students so in list I have the following case;
Case 1: If the teacher review the attendance the of last day , I fetch a list of students that are either absent or present. So on this , the segmented control that I am using in list fires the onCheckChangedlistener which run the code which is also performing some task , where as I only want to perform the task only when user change the listener. In short listener should not fire when I change any check pragmatically. and Also it fires the onCheckChangedListener multiple times. which creates problem for me :
So I have couple of question:
1) what can be used in android in place of the Segmented control library as I stated above.
2) what is possible workaround for this problem. I tried using flag but I am working in getview of listview.
this is a good library in response to what you achieve. I have used this and found the similar problem. So hence by putting flag , and making a raw check over it does a work for me . But As you are using list, i think you can not achieve what you are looking for.
I will suggest to use the radio button to get the check or you can make your custom control like this and see this library

Tutorial first time you enter into an app?

I'm programming an app using android studio. I want to know in which way I can do a tutorial that users will see only the first time that use the app. Tutorial like image or screenshoots
Can someone help me? Thanks
I encountered this thread while looking for a solution for running a tutorial only at the first time (as rbaleksandar suggested), so in case it will be helpful for someone someday, here's a template of a solution that works for me (using the SharedPreferences API):
#Override
protected void onResume() {
super.onResume();
String tutorialKey = "SOME_KEY";
Boolean firstTime = getPreferences(MODE_PRIVATE).getBoolean(tutorialKey, true);
if (firstTime) {
runTutorial(); // here you do what you want to do - an activity tutorial in my case
getPreferences(MODE_PRIVATE).edit().putBoolean(tutorialKey, false).apply();
}
}
EDIT - BONUS - If you're into app tutorial - I'm messing now with the ShowcaseView library (which is amazing - try it out). Apparently they have some shortcut for that issue using a method called singleShot(long) - its input is a key for the SharedPreferences, and it does the exact same thing - runs only in the first activation. Example of usage (taken from here):
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_shot);
Target viewTarget = new ViewTarget(R.id.button, this);
new ShowcaseView.Builder(this)
.setTarget(viewTarget)
.setContentTitle(R.string.title_single_shot)
.setContentText(R.string.R_string_desc_single_shot)
.singleShot(42)
.build();
}
You could always code your own solution, but, let us not reinvent the wheel.
Check this Android Library:
Tour Guide Repository
It allows you to add pointers in your screen, so the user knows where is he supposed to touch next.
It's pretty easy to use, you only need to point to the element you want the user to touch.
From the doc:
Let's say you have a button like this where you want user to click on:
Button button = (Button)findViewById(R.id.button);
You can add the tutorial pointer on top of it by:
TourGuide mTourGuideHandler = TourGuide.init(this).with(TourGuide.Technique.Click)
.setPointer(new Pointer())
.setToolTip(new ToolTip().setTitle("Welcome!").setDescription("Click on Get Started to begin..."))
.setOverlay(new Overlay())
.playOn(button);
Hope this helps!
Some links to libraries for creating introduction and/or tutorial screens.
Horizontal cards like Google Now:
https://github.com/PaoloRotolo/AppIntro
Tutorial screen:
https://github.com/amlcurran/ShowcaseView
As far as I understand the question is not How do I create a tutorial? (as the people who have already posted an answer have concluded) but instead How to show a tutorial upon first launch only?. So here are my two cents on this topic:
I'm not familiar with how your Android app stores its configuration data but I will assume that it's either in a database (SQLite) or a text file (plaintext, YAML, XML - whatever). Add a configuration entry to wherever the app's settings are being stored - something like tutorial_on : false, tutorial_on : 1 etc. depending on the format the configuration is represented in.
The way configurations work is that whenever an app (or software in general) is launched it has to be loaded in the app itself. So add the following to your app (where and how is up to you and your app design):
Check tutorial_on entry
If tutorial_on is set to true/1 whatever
2.1 Display tutorial
2.2 Change tutorial_on to false/0 whatever
2.3 Store the result in your configuration
Continue using the app
By doing so the first time your app launches the flag responsible for displaying the tutorial will be toggled and afterwards every time you start the app the toggle flag will be read leading to omitting the tutorial.
Personally I would suggest that you an option similar to Don't show tutorial anymore along with a description how to re-enable it (by triggering some action in that app's menu etc.). This has two major benefits:
Improved user experience - users like to have control (especially over trivial matters such as showing or hiding a tutorial). Whenever you take the control away from them, they get pissed off.
Enable your user to re-learn forgotten things - a general rule of thumb is to create apps that should not burden the user with a lot of stuff to remember. That is why things should be self-explanatory. However sometimes you may want to do that nonetheless. By adding the possibility that the user re-launches (by simply resetting the tutorial_on flag and repeating the steps from above) the tutorial allows just that - refreshing a user's memory.

Search implementation Questions on android

I am a newbie here and hope you can help me out to clear some of my understanding (or misunderstanding). I have been reading for days and trying out based on Android guide to implement search function but it really didn't work out well. Perhaps I've got the whole concept wrong so do help me out here if you can be kind.
I have an app which data is from remote xml and I want to implement search function. I have 1 main activity (under my SRC -> my package)that list all the data retrieved from the xml. My questions:
1) In the guide, it saws we must define a .Searchable Activity. I supposed this is to handle the search query and store the result? If this is a case, do I need to create a new activity or I can use my main activity as .Searchable Activity?
2) After the above item is done, I supposed I need to create an activity to receive the result and do something. I take it as I need to create "public class SearchableActivity extends ListActivity" in the activity I define in item 1? The problem is that I don't know what to do with this as the guide are incomplete.
3) Presumingly I did it successfully and upon search, there are some results return, how do I show (or filter to show the search result) in my main activity? I do not want to have another UI to show the result as I prefer it just get filter to show the matched records
4) Lastly, since my data is from remote xml, do I need to "search" based on remote xml or it will search based on cache info on the app?
I am sorry for being so ignorant but I am totally new here and hope you can help me out. So far I have no problem, getting the dialog shown on my action bar. The only problem is that the search didn't work at all :( upon search, there is just nothing happened.
Thanks very much in advance. Cheers!
For searching in a list you can use built-in functions of android, but if you want a good result you can use your own function. The simplest function is:
for(int i = 0 ; i < arraylisy.size() ; i++)
{
if(arraylist.get(i) == youobject)
return true;
}
return false;
but there are better functions like binary search that you can use.
Now, how to create search activity?
First: create XML file an add a listview in it.
Second: create java file and link xml file to it.
Now use above code to search an object on your list. If in every search you find several items then add them to new listview.
Now create an adapter and send your search list to that.
Finally set your adapter to listview.

Customizing Android sample app

I'm doing some customizations to this Android sample app: HoneycombGallery.
I need to execute some extra code when a user switches betweens the tabs (Balloons - Pastries) but running into some problems here.
What I need to do specifically is to return the name of the tab (the directory categories) every time a user switches to a new tab. I need that string in the code I'd like to execute every time a user switches tabs. I can't find a way to dynamically do this, or maybe I'm just trying to do it in the wrong java file.
How would you go about this? Any input greatly appreciated. Please let me know if I need to clarify.
Thanks!

Android Graphical UI Builders - Connect event

Maybe this question has been ask already, but could not find any answer for almost 2hours of internet search.
There is a graphical UI designer wich is coming along with the last android SDK.
Looks pretty cool and well done.
Nevertheless I * cannot find how to attach an event to the control through the graphical editor.
Of course I can add it manually into the xml, but in that case, what's the purpose of having such tool without that function ?
I mean all the other SDK I had in other languages always include that function.
I've also not been able to find doc about how to use this tool. Quite sad...
Thanks
If you want to add a click event handler, select the button (widget) in the GUI that you want to listen for, and look for the property onClick. Enter the name of the method you want to call when the user clicks on that widget, like.. onMyButtonClick
Then add the method to your Activity
public void onMyButtonClick(View v) {
// I heard the button click
}
The GUI builder is getting there, and is not yet as easy to use as the one in XCode, but it's not hard when you get used to it.

Categories

Resources