Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void listView()
- {
- textView = (TextView) getView().findViewById(R.id.textView_count);
- int count;
- String dirPath = "/sys/bus/usb/devices";
- File dir = new File(dirPath);
- File[] filelist = dir.listFiles();
- String[] theNamesOfFiles = new String[filelist.length];
- for (int i = 0; i < theNamesOfFiles.length; i++)
- {
- theNamesOfFiles[i] = filelist[i].getName();
- }
- listView = (ListView) getView().findViewById(R.id.listView);
- ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, theNamesOfFiles);
- listView.setAdapter(arrayAdapter);
- listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
- count = listView.getAdapter().getCount();
- textView.setText(count);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
- {
- @Override
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l)
- {
- Intent intent = new Intent(getActivity(),USBInfoAPI.class);
- startActivity(intent);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment