这是我得到的错误:
05-08 12:50:56.976: E/AndroidRuntime(1018): java.lang.NoClassDefFoundError:
nl.h.energy.android.userinterface.FragmentEnergyUsage
我使用了断点,我确定错误在这一行
1 bar.addTab(bar.newTab()
2 .setText("energy usage")
3 .setTabListener(
4 new nl.h.energy.android.helper.TabListener
5 <nl.h.energy.android.userinterface.FragmentEnergyUsage>
6 (this,"energyUsage",
7 nl.h.energy.android.userinterface.FragmentEnergyUsage.class)));
错误发生在第 6/7 行我希望我提供了足够的信息。这些类是我自己编写的类,所以我必须导入这些类或 Android 中缺少这些类没有问题
TabListener 看起来像这样:http: //developer.android.com/reference/android/app/ActionBar.html#newTab ()
FragmentEnergyUsage 类看起来像这样:
package nl.h.energy.android..userinterface;
import nl.h.energy.userinterface.R;
import android.os.Bundle;
import android.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class FragmentEnergyUsage extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e("Test", "hello");
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.energy_usage, container, false);
return view;
}
public void setText(String item) {
TextView view = (TextView) getView().findViewById(R.id.detailsText);
view.setText(item);
}
}