OSDN Git Service

Fix crashing
[android-x86/external-koush-Widgets.git] / README.md
1 ### To do this:
2
3
4 ![](https://raw.github.com/koush/Widgets/master/dark.png)
5 ![](https://raw.github.com/koush/Widgets/master/light.png)
6
7
8 ### Write this:
9
10
11 ```java
12
13 public class MainActivity extends ActivityBase {
14     @Override
15     public void onCreate(Bundle savedInstanceState, View view) {
16         super.onCreate(savedInstanceState, view);
17         
18         addItem("Theme", new ListItem(getFragment(), "Dark Theme", null, R.drawable.ic_launcher) {
19             @Override
20             public void onClick(View view) {
21                 super.onClick(view);
22                 startActivity(new Intent(MainActivity.this, MainActivityDark.class));
23             }
24         });
25         
26         addItem(R.string.cloud, new ListItem(getFragment(), R.string.googledrive, R.string.googledrive_summary, R.drawable.drive) {
27             @Override
28             public void onClick(View view) {
29                 super.onClick(view);
30                 Toast.makeText(MainActivity.this, "You clicked Google Drive!", Toast.LENGTH_SHORT).show();
31             }
32         });
33         addItem(R.string.cloud, new ListItem(getFragment(), R.string.dropbox, 0, R.drawable.dropbox));
34         addItem(R.string.cloud, new ListItem(getFragment(), R.string.box, 0, R.drawable.box));
35         
36         addItem(R.string.devices, new ListItem(getFragment(), "Nexus S", null, R.drawable.nexusone)).setCheckboxVisible(true).setChecked(true);
37         addItem(R.string.devices, new ListItem(getFragment(), "Nexus One", null, R.drawable.nexusone)).setCheckboxVisible(true);
38         addItem(R.string.devices, new ListItem(getFragment(), "Nexus 4", null, R.drawable.nexusone)).setCheckboxVisible(true);
39         addItem(R.string.devices, new ListItem(getFragment(), "Nexus 7", null, R.drawable.nexusone)).setCheckboxVisible(true).setChecked(true);;
40         addItem(R.string.devices, new ListItem(getFragment(), "Nexus 10", null, R.drawable.nexusone)).setCheckboxVisible(true);
41     }
42 }
43
44
45 ```