Я использую шаблон navigation-drawer
в eclipse, чтобы сделать простое приложение для Android. У меня есть некоторые проблемы с фрагментом. я объявил фрагмент под названием PresenceLog Фрагмент в манифесте, но когда я назвал его в MainActivity
, журнал до сих пор говорит, чтоИсключение для Android-фрагмента: активность не найдена
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);
}
Это моя основная информация
private void launchPresenceLog(){
Intent intent = new Intent(this,PresenceLogFragment.class);
startActivity(intent);
}
Было бы здорово, если бы вы знали, что не так с моим кодом. Кроме того, поскольку я новичок в программировании на Android, я был бы признателен, если бы вы предложили некоторые онлайн-курсы.
вы не добавили добавляемые активность в вашем файл манифеста – ashutiwari4
Курс: https://www.udacity.com/course/ud853 –
@ ashutiwari4 Он пытается запустить ФРАГМЕНТ, используя INTENT в качестве ДЕЯТЕЛЬНОСТИ. Это совершенно неверно, см. Https://developer.android.com/training/basics/fragments/creating.html – EpicPandaForce