Back to project page pinpoint-android.
The source code is released under:
MIT License
If you think the Android project pinpoint-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package co.islovely.pinpoint; //from www . j a va2 s. co m import android.app.Activity; import android.content.res.Resources; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; import java.util.List; public class HomescreenSelectActivity extends Activity { private HomescreenAdapter adapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.homescreenselect); List<Homescreen> homescreenList = new ArrayList<Homescreen>(); for (LauncherItem launcherItem : LauncherReader.getAllItemsNotInDock(this)) { int screenId = launcherItem.getScreen(); Homescreen homescreen = null; for (Homescreen preexistingHomescreen : homescreenList) { if (preexistingHomescreen.getId() == screenId) { homescreen = preexistingHomescreen; break; } } if (null == homescreen) { homescreen = new Homescreen(screenId); homescreenList.add(homescreen); } homescreen.addLauncherItem(launcherItem); } ListView listView = (ListView) this.findViewById(R.id.list); this.adapter = new HomescreenAdapter(this); this.adapter.addAll(homescreenList); listView.setAdapter(adapter); } public void selectHomescreen(View view) { Configuration configuration = Configuration.getInstance(); Resources resources = this.getResources(); String tag = view.getTag().toString(), tagFirst = resources.getString(R.string.tag_homescreenselect_first), tagSecond = resources.getString(R.string.tag_homescreenselect_second), tagThird = resources.getString(R.string.tag_homescreenselect_third); int id = Integer.parseInt( ((TextView) ( (ViewGroup) view.getParent().getParent() ).findViewById(R.id.id) ).getText().toString(), 10); if (tag.equals(tagFirst)) { configuration.setFirstHomescreenId(id); } else if (tag.equals(tagSecond)) { configuration.setSecondHomescreenId(id); } else if (tag.equals(tagThird)) { configuration.setThirdHomescreenId(id); } // restore original background color for all buttons with the same tag as // this button ViewGroup viewGroup = (ViewGroup) view.getParent().getParent().getParent(); for (int i = 0, l = viewGroup.getChildCount(); i < l; i++) { ((ViewGroup) viewGroup.getChildAt(i).findViewById(R.id.buttons)).findViewWithTag(view.getTag()).setBackgroundResource(R.color.gray); } // restore original background color for all buttons in the same view group viewGroup = (ViewGroup) view.getParent(); for (int i = 0, l = viewGroup.getChildCount(); i < l; i++) { viewGroup.getChildAt(i).setBackgroundResource(R.color.gray); } // color only selected button view.setBackgroundResource(R.color.orange); } }