setting some checkbox to true by default for a custom ArrayAdapter - android

I am working on an Android app right now that will put shortcuts of apps onto the home screen.
I have everything working fine right now.
Currently the user is presented with a list of applications that are installed and they can multi select from the list with CheckBox's. However, I would like my application to already have some of the applications in the list checked by default when the user launches the app.
For instance, when the user first launches the application there are 3 of the apps that are selected by default ( for what ever reason, can be hard coded or in a properties file this does not matter right now ).
How can i do this? I basically need to be able to compare the name of the scanned application against a name in a properties file and if they match, check it by default. I have tried a couple ways and am lost. Can someone point me in the right direction or give me some hints here?
Getting the reference to the CheckBox associated with an item in the list from the custom ArrayAdapter seems to be my issue.
Thanks

I decided to basically create a class that would contain the information regarding the shortcuts. And in the class it had a boolean for holding on to the state of the selection of the checkbox. Basiclly using a MVC pattern.
Then i updated my getView() in my adapter. And added a method in my main activity for setting the default selected. Then added a method in my adapter to set the checked shortcuts and notifyDataSetChanged() everytime a change was made.
If anyone would like more detail, just comment here and i can add code if needed.

Related

save layout back into xml

I am working on a project where I have multiple tabs, and I want the content of each tab to be set dynamically based on what is selected in the previous tab. (For my tabs, I am using the SlidingTabLayout with a ViewPager). I currently have my first tab set up correctly and have it tied to an EventBus that creates a LinearLayout based off of my template from R.layouts.tab_2 and adds the content dynamically. What I can't quite figure out is how to save my LinearLayout back into the tab_2.xml file. I have seen suggestions of saving it with SharedPreferences, but that doesn't allow me to save it as the right file type.
If there is a much easier way to do this, such as updating the tab that is already created, I am open to that instead of saving the layout back into the XML file. I am fairly new at programming in Android Studio and still trying to get the basics down.
Your first tab, as I'm interpreting it, is essentially a settings page. The user does a few things, and as a result of those things - the layout on your second tab looks different.
You need to save some variables based on user interactions. For example, if you have a checkbox the user is going to press - you would set a boolean to true when they've checked it, and false when they've unchecked it. When the user navigates to your second tab, you will check the value of that boolean - and alter that layout accordingly.
Hopefully this concept will, even in its simplicity - help you understand how apps are built to be functional.

Best control to be used as dropdown list in android

I have an activity which one of its components is a EditText. The goal of it is the following: when user clicks/taps on it, another activity is called to select some items (categories). I have implemented it using an activity that extends listactivity and using a custom adapter to paint custom rows for items.
All is ok, but I guess if using a EditText is the best option. The problem using this kind of control is that when user clicks/taps on it, the virtual keyboard appears and I do not want it to appear. If I use a TextView instead, virtual keyboard does not appear, but it is not clear for user that he have to click/tap on it to select a category (as the underscore line is not shown here as when using EditText).
So what android widget is the best to use in this scenario?
You can always use expandable list view there are many examples online that could help u to create it much more flexible than a spinner and it looks elegant and easy to use, it also show the user directly what is used for by just giving it a look and u can always customize it and play with its look and functionality.
Sounds like you are looking for a Spinner? That way you wouldn't have to load up a separate Activity to make the category selection. Otherwise, why not just use a Button? It's obviously clickable, that's for sure!

How to pass data among the screens in sencha touch2.0?

I am working on sencha touch2.0 app and I want to send data from one screen to another. I know this question has already been asked here but I don't find it helpful so I am asking it here again.
I have a checkbox listview in my app and what I want is that when I click on one or more checkboxes and go to next screen, I will get all the 'checked' list items here, means I want to send checked list items data from one screen to another. From my research on net I came to know, this can be done by dispatch() method http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Application-method-dispatch. But I don't how to do it. So, please provide me any suggestion/solution to get rid of these problem.
Ext.dispatch() is deprecated in Sencha Touch 2.0 because of the fact that you can always call any method of any controller at anytime you want through this, right in your views:
yourAppName.getApplication().getController.method(params)
Or even further, you can make it automatic through refs and controls in your controller.

android 4.0 spinner usage

I want to be able to do what is on the picture, provided by this link, under the "Allow cutting through hierarchies" section. I thought that I could do that using a spinner, but from the android documentation I realized that a spinner can show one child at a time and lets the user pick among them. In my case, (and from the example I provided), you have some other text displayed, and then you can choose from some other options provided in sth that looks like a popup, list that contains the things that i want to choose from. I don't know how this is implemented, but it's used in the google music app for android 4.0. If someone has an idea, have implemented sth like this, please give me some advice.
It is not a spinner. Its just a view (in the Mail app a relative layout) See here
On click this View opens a popupmenu.
Therefore it is looking like a spinner but you can add you custom behaviour.

adding applications onto the widgets list present in home screen

Hie all ,
I am trying to create an simple application and i want that application to show in the widgets list, i.e on long press on the idle home screen it pops up a spinner for us , you can see it in the below figure,
in that you can see item called widgets which list some set of the applications, even you can see that in the next diagram.. My requirement is that i want my application to be listed there rather showing the general applications list.
thanks
datta
You need to create a widget application
see these tutorials
http://www.vogella.de/articles/AndroidWidgets/article.html

Categories

Resources