1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package #package_name#; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.widget.*; 22 import android.view.*; 23 24 import #ManifestPackageName#.R; 25 26 public class #class_name# extends Activity { 27 28 private ViewGroup feature_1; 29 private ViewGroup feature_2; 30 private ViewGroup feature_3; 31 private ViewGroup feature_4; 32 private ViewGroup feature_5; 33 private ViewGroup feature_6; 34 35 /** 36 * @see android.app.Activity#onCreate(Bundle) 37 */ 38 @Override 39 protected void onCreate(Bundle savedInstanceState) { 40 super.onCreate(savedInstanceState); 41 setContentView(R.layout.#layout_name#dashboard_pattern/dashboard_layout.xml#); 42 43 this.feature_1 = (ViewGroup) findViewById(R.id.feature_1); 44 this.feature_2 = (ViewGroup) findViewById(R.id.feature_2); 45 this.feature_3 = (ViewGroup) findViewById(R.id.feature_3); 46 this.feature_4 = (ViewGroup) findViewById(R.id.feature_4); 47 this.feature_5 = (ViewGroup) findViewById(R.id.feature_5); 48 this.feature_6 = (ViewGroup) findViewById(R.id.feature_6); 49 50 View.OnClickListener onClickListener = new DashboardClickListener(); 51 52 this.feature_1.setOnClickListener(onClickListener); 53 this.feature_2.setOnClickListener(onClickListener); 54 this.feature_3.setOnClickListener(onClickListener); 55 this.feature_4.setOnClickListener(onClickListener); 56 this.feature_5.setOnClickListener(onClickListener); 57 this.feature_6.setOnClickListener(onClickListener); 58 59 } 60 61 private class DashboardClickListener implements View.OnClickListener{ 62 63 public void onClick(View v) { 64 65 /* 66 * TODO: Replace the code below with your business logic 67 * 68 * You will probably open an activity, which can be done using a code like below: 69 * startActivity(new Intent(v.getContext(), YourActivity.class)); 70 */ 71 72 String msg = "You selected Feature "; 73 74 switch(v.getId()){ 75 case R.id.feature_1: 76 msg += "1"; 77 break; 78 case R.id.feature_2: 79 msg += "2"; 80 break; 81 case R.id.feature_3: 82 msg += "3"; 83 break; 84 case R.id.feature_4: 85 msg += "4"; 86 break; 87 case R.id.feature_5: 88 msg += "5"; 89 break; 90 case R.id.feature_6: 91 msg += "6"; 92 break; 93 default: 94 // none 95 } 96 97 Toast.makeText(v.getContext(), msg, Toast.LENGTH_SHORT).show(); 98 } 99 100 } 101 102 } 103