1 public class MainActivity extends FragmentActivity { 2 3 private SlidingMenu mSlidingMenu; 4 5 @Override 6 protected void onCreate(Bundle savedInstanceState) { 7 super.onCreate(savedInstanceState); 8 requestWindowFeature(Window.FEATURE_NO_TITLE); 9 setContentView(R.layout.activity_main); 10 11 int screenWidth = getResources().getDisplayMetrics().widthPixels; 12 13 mSlidingMenu = new SlidingMenu(this); 14 mSlidingMenu.setMenu(R.layout.empty_left_menu); 15 mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); 16 mSlidingMenu.setBehindWidth((int) (screenWidth * 0.73f)); 17 mSlidingMenu.setMode(SlidingMenu.LEFT); 18 mSlidingMenu.setBackgroundResource(R.drawable.left_fra_bg); 19 mSlidingMenu.setTranslateZoonMode(true); 20 mSlidingMenu.attachToActivity(this, 0); 21 22 FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); 23 ft.replace(R.id.left_empty_layout, new LeftMenuFragment()); 24 ft.replace(R.id.content_empty_layout, new ContentFragment()); 25 ft.commit(); 26 } 27 }
1 public class LeftMenuFragment extends Fragment { 2 3 @Override 4 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 5 return inflater.inflate(R.layout.fgm_left, container, false); 6 } 7 8 @Override 9 public void onActivityCreated(Bundle savedInstanceState) { 10 super.onActivityCreated(savedInstanceState); 11 12 View view = getView(); 13 14 view.findViewById(R.id.btn1); 15 } 16 }
1 public class ContentFragment extends Fragment implements OnCheckedChangeListener { 2 3 @Override 4 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 5 return inflater.inflate(R.layout.fgm_content, container, false); 6 } 7 8 @Override 9 public void onActivityCreated(Bundle savedInstanceState) { 10 super.onActivityCreated(savedInstanceState); 11 12 View view = getView(); 13 14 ((RadioButton) view.findViewById(R.id.jiujiu)).setOnCheckedChangeListener(this); 15 ((RadioButton) view.findViewById(R.id.buy)).setOnCheckedChangeListener(this); 16 ((RadioButton) view.findViewById(R.id.good)).setOnCheckedChangeListener(this); 17 ((RadioButton) view.findViewById(R.id.me)).setOnCheckedChangeListener(this); 18 } 19 20 @Override 21 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 22 23 } 24 }
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" 6 android:paddingBottom="22dp" 7 android:paddingLeft="18dp" 8 android:paddingRight="12dp" 9 android:paddingTop="35dp" > 10 11 <TextView 12 android:layout_width="match_parent" 13 android:layout_height="wrap_content" 14 android:background="@drawable/left_fra_search_bg" 15 android:gravity="center_vertical" 16 android:text="点击搜索" 17 android:textColor="@android:color/darker_gray" /> 18 19 <LinearLayout 20 android:layout_width="match_parent" 21 android:layout_height="wrap_content" 22 android:layout_marginTop="17dp" 23 android:orientation="horizontal" > 24 25 <Button 26 android:id="@+id/btn1" 27 android:layout_width="0dp" 28 android:layout_height="wrap_content" 29 android:layout_weight="1" 30 android:background="@drawable/left_btn_selector" 31 android:drawablePadding="5dp" 32 android:drawableTop="@drawable/ico1" 33 android:paddingBottom="9dp" 34 android:paddingTop="9dp" 35 android:text="TOP" 36 android:textColor="@android:color/darker_gray" 37 android:textSize="13sp" /> 38 39 <Button 40 android:id="@+id/btn2" 41 android:layout_width="0dp" 42 android:layout_height="wrap_content" 43 android:layout_weight="1" 44 android:background="@drawable/left_btn_selector" 45 android:drawablePadding="5dp" 46 android:drawableTop="@drawable/ico2" 47 android:paddingBottom="9dp" 48 android:paddingTop="9dp" 49 android:text="数码" 50 android:textColor="@android:color/darker_gray" 51 android:textSize="13sp" /> 52 53 <Button 54 android:id="@+id/btn3" 55 android:layout_width="0dp" 56 android:layout_height="wrap_content" 57 android:layout_weight="1" 58 android:background="@drawable/left_btn_selector" 59 android:drawablePadding="5dp" 60 android:drawableTop="@drawable/ico3" 61 android:paddingBottom="9dp" 62 android:paddingTop="9dp" 63 android:text="女装" 64 android:textColor="@android:color/darker_gray" 65 android:textSize="13sp" /> 66 </LinearLayout> 67 68 <LinearLayout 69 android:layout_width="match_parent" 70 android:layout_height="wrap_content" 71 android:layout_marginTop="6dp" 72 android:orientation="horizontal" > 73 74 <Button 75 android:id="@+id/btn4" 76 android:layout_width="0dp" 77 android:layout_height="wrap_content" 78 android:layout_weight="1" 79 android:background="@drawable/left_btn_selector" 80 android:drawablePadding="5dp" 81 android:drawableTop="@drawable/ico4" 82 android:paddingBottom="9dp" 83 android:paddingTop="9dp" 84 android:text="男装" 85 android:textColor="@android:color/darker_gray" 86 android:textSize="13sp" /> 87 88 <Button 89 android:id="@+id/btn5" 90 android:layout_width="0dp" 91 android:layout_height="wrap_content" 92 android:layout_weight="1" 93 android:background="@drawable/left_btn_selector" 94 android:drawablePadding="5dp" 95 android:drawableTop="@drawable/ico5" 96 android:paddingBottom="9dp" 97 android:paddingTop="9dp" 98 android:text="家具" 99 android:textColor="@android:color/darker_gray" 100 android:textSize="13sp" /> 101 102 <Button 103 android:id="@+id/btn6" 104 android:layout_width="0dp" 105 android:layout_height="wrap_content" 106 android:layout_weight="1" 107 android:background="@drawable/left_btn_selector" 108 android:drawablePadding="5dp" 109 android:drawableTop="@drawable/ico6" 110 android:paddingBottom="9dp" 111 android:paddingTop="9dp" 112 android:text="母婴" 113 android:textColor="@android:color/darker_gray" 114 android:textSize="13sp" /> 115 </LinearLayout> 116 117 <LinearLayout 118 android:layout_width="match_parent" 119 android:layout_height="wrap_content" 120 android:layout_marginTop="6dp" 121 android:orientation="horizontal" > 122 123 <Button 124 android:id="@+id/btn7" 125 android:layout_width="0dp" 126 android:layout_height="wrap_content" 127 android:layout_weight="1" 128 android:background="@drawable/left_btn_selector" 129 android:drawablePadding="5dp" 130 android:drawableTop="@drawable/ico7" 131 android:paddingBottom="9dp" 132 android:paddingTop="9dp" 133 android:text="鞋包" 134 android:textColor="@android:color/darker_gray" 135 android:textSize="13sp" /> 136 137 <Button 138 android:id="@+id/btn8" 139 android:layout_width="0dp" 140 android:layout_height="wrap_content" 141 android:layout_weight="1" 142 android:background="@drawable/left_btn_selector" 143 android:drawablePadding="5dp" 144 android:drawableTop="@drawable/ico8" 145 android:paddingBottom="9dp" 146 android:paddingTop="9dp" 147 android:text="配饰" 148 android:textColor="@android:color/darker_gray" 149 android:textSize="13sp" /> 150 151 <Button 152 android:id="@+id/btn9" 153 android:layout_width="0dp" 154 android:layout_height="wrap_content" 155 android:layout_weight="1" 156 android:background="@drawable/left_btn_selector" 157 android:drawablePadding="5dp" 158 android:drawableTop="@drawable/ico9" 159 android:paddingBottom="9dp" 160 android:paddingTop="9dp" 161 android:text="没装" 162 android:textColor="@android:color/darker_gray" 163 android:textSize="13sp" /> 164 </LinearLayout> 165 166 <LinearLayout 167 android:layout_width="match_parent" 168 android:layout_height="wrap_content" 169 android:layout_marginTop="6dp" 170 android:orientation="horizontal" > 171 172 <Button 173 android:id="@+id/btn10" 174 android:layout_width="0dp" 175 android:layout_height="wrap_content" 176 android:layout_weight="1" 177 android:background="@drawable/left_btn_selector" 178 android:drawablePadding="5dp" 179 android:drawableTop="@drawable/ico10" 180 android:paddingBottom="9dp" 181 android:paddingTop="9dp" 182 android:text="美食" 183 android:textColor="@android:color/darker_gray" 184 android:textSize="13sp" /> 185 186 <Button 187 android:id="@+id/btn11" 188 android:layout_width="0dp" 189 android:layout_height="wrap_content" 190 android:layout_weight="1" 191 android:background="@drawable/left_btn_selector" 192 android:drawablePadding="5dp" 193 android:drawableTop="@drawable/ico11" 194 android:paddingBottom="9dp" 195 android:paddingTop="9dp" 196 android:text="百货" 197 android:textColor="@android:color/darker_gray" 198 android:textSize="13sp" /> 199 200 <Button 201 android:id="@+id/btn12" 202 android:layout_width="0dp" 203 android:layout_height="wrap_content" 204 android:layout_weight="1" 205 android:background="@drawable/left_btn_selector" 206 android:drawablePadding="5dp" 207 android:drawableTop="@drawable/ico12" 208 android:paddingBottom="9dp" 209 android:paddingTop="9dp" 210 android:text="手机充值" 211 android:textColor="@android:color/darker_gray" 212 android:textSize="13sp" /> 213 </LinearLayout> 214 215 <RelativeLayout 216 android:layout_width="match_parent" 217 android:layout_height="match_parent" 218 android:paddingLeft="30dp" > 219 220 <CheckBox 221 android:layout_width="wrap_content" 222 android:layout_height="wrap_content" 223 android:layout_alignParentBottom="true" 224 android:button="@null" 225 android:drawablePadding="17dp" 226 android:drawableRight="@drawable/browse_selector" 227 android:text="浏览模式" 228 android:textColor="@android:color/darker_gray" 229 android:textSize="18sp" /> 230 </RelativeLayout> 231 232 </LinearLayout>
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 7 <FrameLayout 8 android:id="@+id/content" 9 android:layout_width="match_parent" 10 android:layout_height="0dp" 11 android:layout_weight="1" > 12 </FrameLayout> 13 14 <RadioGroup 15 android:layout_width="match_parent" 16 android:layout_height="65dp" 17 android:background="@drawable/tabbar_bg" 18 android:orientation="horizontal" > 19 20 <RadioButton 21 android:id="@+id/jiujiu" 22 android:layout_width="0dp" 23 android:layout_height="match_parent" 24 android:layout_weight="1" 25 android:background="@drawable/tab_selector" 26 android:button="@null" 27 android:drawablePadding="3dp" 28 android:drawableTop="@drawable/tab_jiujiu" 29 android:gravity="center" 30 android:padding="10dp" 31 android:text="九块九" 32 android:textColor="@android:color/white" 33 android:textSize="13sp" /> 34 35 <RadioButton 36 android:id="@+id/buy" 37 android:layout_width="0dp" 38 android:layout_height="match_parent" 39 android:layout_weight="1" 40 android:background="@drawable/tab_selector" 41 android:button="@null" 42 android:drawablePadding="3dp" 43 android:drawableTop="@drawable/tab_buy" 44 android:gravity="center" 45 android:padding="10dp" 46 android:text="超值购" 47 android:textColor="@android:color/white" 48 android:textSize="13sp" /> 49 50 <RadioButton 51 android:id="@+id/good" 52 android:layout_width="0dp" 53 android:layout_height="match_parent" 54 android:layout_weight="1" 55 android:background="@drawable/tab_selector" 56 android:button="@null" 57 android:drawablePadding="3dp" 58 android:drawableTop="@drawable/tab_good" 59 android:gravity="center" 60 android:padding="10dp" 61 android:text="值得买" 62 android:textColor="@android:color/white" 63 android:textSize="13sp" /> 64 65 <RadioButton 66 android:id="@+id/me" 67 android:layout_width="0dp" 68 android:layout_height="match_parent" 69 android:layout_weight="1" 70 android:background="@drawable/tab_selector" 71 android:button="@null" 72 android:drawablePadding="3dp" 73 android:drawableTop="@drawable/tab_me" 74 android:gravity="center" 75 android:padding="10dp" 76 android:text="我的" 77 android:textColor="@android:color/white" 78 android:textSize="13sp" /> 79 </RadioGroup> 80 81 </LinearLayout>
时间: 2024-09-28 22:16:39