您好我试图显示android.view包中存在的所有类
包在jar文件中。这将通过java反射concept.how进行访问
该
类和我想在Android列表视图中显示任何人都可以帮助我..“
这是我的Display class_list.java文件
public static void main(){
List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
classLoadersList.add(ClasspathHelper.getContextClassLoader());
classLoadersList.add(ClasspathHelper.getStaticClassLoader());
// Reflections reflections1 = new Reflections("Doc");
Reflections reflections = new Reflections(new ConfigurationBuilder()
.setScanners(new SubTypesScanner(), new ResourcesScanner())
.setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
.filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("android.view"))));
Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
//System.out.println(classes);
Log.i("Ram","class name "+ classes);
Iterator it=classes.iterator();
while(it.hasNext()){
Class c=(Class) it.next();
int i;
String classname = c.getName();
Displayclass.your_array_list3.add(classname);
Log.i("Ram","class name "+ c.getName());
}
}
}
这是我的活动档案
public class Displayclass extends Activity {
public static ArrayList<String> your_array_list3 = new ArrayList<String>();
Intent StartLsit;
private Displayclass dl;
@Override
protected void onPostCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onPostCreate(savedInstanceState);
setContentView(R.layout.displayclass);
Button class_button =(Button)findViewById(R.id.classbutton2);
class_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent clIntent = new Intent (v.getContext(),Displayclass_list.class);
v.getContext().startActivity(clIntent);
}
});}
public void doclass(View v)
{
Log.i("send","I am in send function");
StartLsit = new Intent(Displayclass.this,Displayclass_list.class);
startActivity(StartLsit);
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
ArrayAdapter<String> arrayAdapter3 = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, your_array_list3 );
dl.setAdapter(arrayAdapter3);
try {
DisplayM.main();
} catch (Exception e) {
e.printStackTrace();
}
// if (ViewClass.theEnd)
// your_array_list.add(ViewClass.methods);
int lst = 0;
for(int i=0; i<lst; i++)
{
}
}
private void setAdapter(ArrayAdapter<String> arrayAdapter3) {
// TODO Auto-generated method stub
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
}
}