我正在使用navigation-drawer
eclipse 中的模板来做一个简单的 Android 应用程序。我在片段方面遇到了一些麻烦。我在清单中声明了一个名为 PresenceLog Fragment 的片段,但是当我调用它时MainActivity
,日志仍然说
03-23 13:54:50.817: E/AndroidRuntime(16750): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.singtel.ricecooker/com.singtel.ricecooker.PresenceLogFragment}; have you declared this activity in your AndroidManifest.xml?
这是我的清单
这是我的片段类
public class PresenceLogFragment extends Fragment{
private TextView myText = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.presence_log, null);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
ArrayList<String> userList = null;
RiceServerRequest newRequest = new RiceServerRequest();
//newRequest.getRequestInfo(this);
}
public void updateUserList(ArrayList<String> userList){
LinearLayout lView = (LinearLayout) getView().findViewById (R.layout.presence_log);
//LinearLayout ll = (LinearLayout)fragment.getView().findViewById(R.id.commentFragmentLayout);
for (int i = 0; i < userList.size();i++){
myText = new TextView(getActivity());
myText.setText(userList.get(i));
lView.addView(myText);
}
//setContentView(lView);
}
这是我的 MainActivity
private void launchPresenceLog(){
Intent intent = new Intent(this,PresenceLogFragment.class);
startActivity(intent);
}
如果您知道我的代码有什么问题,那就太好了。另外,由于我是 Android 编程新手,如果您能推荐一些在线课程,我将不胜感激。