I have a login page occupying first half of the screen containing fields like 2 EditText
for email and password and Button
. The second half contains a ListFragment
with public projects. If the user successfully logs in, a new Activity should start containing the same Fragment
of the MainActivity but withe different data - the user created projects. I have successfully made the MainActivity, but the next activity after the user logs in fails to start. The exception:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.amangrover.finalapp1/com.example.amangrover.finalapp1.ProjectListFragment}; have you declared this activity in your AndroidManifest.xml?
private_projects_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="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_width="match_parent"
android:layout_height="wrap_content"
class="com.example.amangrover.finalapp1.ProjectListFragment"
android:id="@+id/privateProjectFragment"/>
</LinearLayout>
ProjectListFragment.java:
public class ProjectListFragment extends ListFragment{
String[] projectTitle;
String[] projectImage;
CustomAdapter adapter;
private List<RowItem> rowItems;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.list_fragment, null, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Bundle args = getActivity().getIntent().getExtras();
projectTitle = args.getStringArray("projectTitle");
projectImage = args.getStringArray("imageId");
rowItems = new ArrayList<RowItem>();
for(int i=0; i<projectTitle.length; i++) {
RowItem item = new RowItem(projectTitle[i], 0);
rowItems.add(item);
}
adapter = new CustomAdapter(getActivity(), rowItems);
setListAdapter(adapter);
}
}
I am using CustomAdapter with this list. Although now I understand that ProjectListFragment.java
is not an activity, so it can't start with intents. So how can I achieve what I want?