目的是要選擇一個手機安裝了的app,本來有一個點擊監聽事件,然後有listView點擊選擇這個app,但是我現在想要通過adb命令傳入一個包名來持續選擇,而不是需要一次次的點擊,請問該用哪種方法實現。
下面是點擊事件監聽的代碼:
mExpandableList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
TextView txtPackage = (TextView) v.findViewById(R.id.txtListPkg);
TextView txtAppName = (TextView) v.findViewById(R.id.txtListItem);
loadSelectedApp(txtPackage.getText().toString()); //加載選定的app的信息
TextView txtAppSelected = (TextView) view.findViewById(R.id.txtAppSelected);
txtAppSelected.setText(">>> " + txtPackage.getText().toString());
Toast.makeText(context, "" + txtAppName.getText().toString(), Toast.LENGTH_SHORT).show();
loadListView(view);
return true;
}
});
你自己代碼裡面把所有的apk自動解析出來不就好了?