如题,我用转入一般Activity 的方法总是会报错
运行的时候总要报ClassNotFoundException,很郁闷,新手,求高手指导。
我是按照一般的转入一个Activity的方法来操作的,是不是这样不对呢?求大家帮帮忙,谢谢~~~~~主程序代码:
package james.chen;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MyListActivity_01Activity extends Activity {private Button move_to_list = null;    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        move_to_list = (Button)findViewById(R.id.move_to_list);
        move_to_list.setOnClickListener(new ToListListener());
    }
    
    class ToListListener implements OnClickListener{
     public void onClick(View v){
      Intent intent = new Intent(MyListActivity_01Activity.this,MyListActivity.class);
      startActivity(intent);
     }
    }
}下面是ListActivity代码:package james.chen;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class MyListActivity extends ListActivity {ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
HashMap<String,String> map1 = new HashMap<String,String>();
HashMap<String,String> map2 = new HashMap<String,String>();    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);
        map1.put("user_name", "张三");
        map1.put("user_ip", "192.168.0.1");
        map2.put("user_name","李四");
        map2.put("user_ip", "192.168.0.2");
        list.add(map1);
        list.add(map2);
        
        SimpleAdapter listAdapter = new SimpleAdapter(this,list,
          R.layout.item,new String[]{"user_name","user_ip"},new int[]{R.id.user_name,R.id.user_ip});
        setListAdapter(listAdapter);
    }
}下面是配置文件:
1.main.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
<Button
android:id="@+id/move_to_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="启动一个listActivity" 
/>
</LinearLayout>
2:item.xml<?xml version="1.0" encoding="utf-8"?>
<LineaLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="1dip"
android:paddingBottom="1dip"
>
<TextView
  android:id="@+id/user_name"
  android:layout_width="180dip"
  android:layout_height="30dip"
  android:textSize="10pt"
  android:singleLine="true"
  />
<TextView
  android:id="@+id/user_ip"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:gravity="right"
  android:textSize="10pt"
  />
</LineaLayout>
3.list.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<LinearLayout
  android:id="@+id/listLinearLayout"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  >
  <ListView
   android:id="@id/android:list"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:drawSelectorOnTop="false"
   android:scrollbars="vertical" 
   >
  </ListView>
</LinearLayout>
</LinearLayout>4.xxxxmanifest.xml<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="james.chen"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MyListActivity_01Activity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
  <activity android:name=".MyListActivity"></activity>
    </application>
</manifest>

解决方案 »

  1.   

    看晕了,发我邮箱,我帮你,[email protected]
      

  2.   

    害我找了找了大半天,楼主您看下item.xml文件的最外层标签,你把LinearLayout打成了LineaLayout,少了一个‘r’,系统帮你布局的时候当然找不到相应的布局类来帮你布局,自然就报ClassNotFound异常了。还要一个建议就是,很对在使用eclipse时候,多按‘Alt + /’来索引,这样就会减少打错的概率。楼主给我加分哈!!!