- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当尝试加载来自另一个 fragment 布局的 fragment 时,我的应用程序停止了。
查看 logcat 时出现此错误:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.flow/com.example.flow.displayClasses.GroupScreens.HomeGroupFragment}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2005)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673)
at android.app.Activity.startActivityForResult(Activity.java:4586)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:234)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:881)
at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:995)
at android.support.v4.app.Fragment.startActivity(Fragment.java:1084)
at android.support.v4.app.Fragment.startActivity(Fragment.java:1073)
at com.example.flow.displayClasses.GroupScreens.GroupsFragment$1.onItemClick(GroupsFragment.java:170)
at android.widget.AdapterView.performItemClick(AdapterView.java:318)
at android.widget.AbsListView.performItemClick(AbsListView.java:1159)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3136)
at android.widget.AbsListView$3.run(AbsListView.java:4052)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
我从哪里来的 fragment :
package com.example.flow.displayClasses.GroupScreens;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.amigold.fundapter.BindDictionary;
import com.amigold.fundapter.FunDapter;
import com.amigold.fundapter.extractors.StringExtractor;
import com.example.flow.R;
import com.amigold.fundapter.BindDictionary;
import com.amigold.fundapter.FunDapter;
import com.amigold.fundapter.extractors.StringExtractor;
import android.content.Intent;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.example.flow.classes.Friends;
import com.example.flow.classes.Group;
import com.example.flow.classes.User;
import com.example.flow.displayClasses.FriendsScreen.FriendsFragment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.view.MenuItem;
import android.support.annotation.Nullable;
import android.widget.Toast;
public class GroupsFragment extends Fragment {
private final String TAG = this.getClass().getSimpleName();
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
private String mParam1;
private String mParam2;
ArrayList<Group> groups = new ArrayList<Group>();
public GroupsFragment() {
// Required empty public constructor
}
public static GroupsFragment newInstance(String param1, String param2) {
GroupsFragment fragment = new GroupsFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View RootView = inflater.inflate(R.layout.fragment_groups, container, false);
// Hardcoded for testing
User u1 = new User("Bram", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u2 = new User("Bram1", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u3 = new User("Bram2", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u4 = new User("Bram3", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u5 = new User("Bram4", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u6 = new User("Bram5", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u7 = new User("Bram6", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u8 = new User("Bram7", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u9 = new User("Bram8", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u10 = new User("Bram9", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u11 = new User("Bram10", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u12 = new User("Bram11", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u13 = new User("Bram12", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u14 = new User("Bram13", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u15 = new User("Bram14", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u16 = new User("Bram15", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u17 = new User("Bram16", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
User u18 = new User("Bram17", "bram.de.plekker@student.ehb.be", "1234", "Captain Plek");
ArrayList<User> ug1 = new ArrayList<User>();
ug1.add(u1);
ug1.add(u2);
ug1.add(u3);
ArrayList<User> ug2 = new ArrayList<User>();
ug2.add(u4);
ug2.add(u5);
ug2.add(u6);
//Collections.addAll(ug1, u4, u5, u6);
ArrayList<User> ug3 = new ArrayList<User>();
ug3.add(u1);
ug3.add(u7);
ug3.add(u8);
ug3.add(u9);
//Collections.addAll(ug1, u7, u8, u9);
ArrayList<User> ug4 = new ArrayList<User>();
Collections.addAll(ug1, u10, u11, u12);
ArrayList<User> ug5 = new ArrayList<User>();
Collections.addAll(ug1, u13, u14, u15);
ArrayList<User> ug6 = new ArrayList<User>();
Collections.addAll(ug1, u14, u5, u6);
ArrayList<User> ug7 = new ArrayList<User>();
Collections.addAll(ug1, u4, u10, u6, u18, u17);
ArrayList<User> ug8 = new ArrayList<User>();
Collections.addAll(ug1, u4, u5, u6);
Group g1 = new Group(1, ug1, u1, "budies", u1, "date", true);
Group g8 = new Group(2, ug1, u1, "budies", u1, "date", false);
Group g9 = new Group(3, ug1, u1, "budies", u1, "date", true);
Group g10 = new Group(4, ug1, u1, "budies", u1, "date", false);
Group g11 = new Group(5, ug1, u1, "budies", u1, "date", true);
Group g12 = new Group(6, ug1, u1, "budies", u1, "date", false);
Group g13 = new Group(7, ug1, u1, "budies", u1, "date", false);
Group g14 = new Group(8, ug1, u1, "budies", u1, "date", false);
Group g15 = new Group(9, ug1, u1, "budies", u1, "date", true);
Group g16 = new Group(10, ug1, u1, "budies", u1, "date", true);
Group g17 = new Group(11, ug1, u1, "budies", u1, "date", true);
Group g18 = new Group(12, ug1, u1, "budies", u1, "date", false);
Collections.addAll(groups, g1, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18);
ListView list = (ListView)RootView.findViewById(R.id.listView);
CustomAdapter adapter = new CustomAdapter();
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Intent intent = new Intent(getActivity().getApplicationContext(), HomeGroupFragment.class);
intent.putExtra("group", groups.get(position));
startActivity(intent);
}
});
return RootView;
}
class CustomAdapter extends BaseAdapter {
int index;
@Override
public int getCount() {
return groups.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int id) {
return id ;
}
public View getView(int i, View view, ViewGroup viewgroup) {
if (groups.get(i).isPrepaid()) {
view = getLayoutInflater().inflate(R.layout.groups_prepaid_layout, null);
} else {
view = getLayoutInflater().inflate(R.layout.groups_layout, null);
}
TextView textView = view.findViewById(R.id.Groupname);
ImageView image = view.findViewById(R.id.member);
String t = groups.get(i).getName();
textView.setText(t);
return view;
}
}
}
不会加载的 fragment :
package com.example.flow.displayClasses.GroupScreens;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.amigold.fundapter.BindDictionary;
import com.amigold.fundapter.FunDapter;
import com.amigold.fundapter.extractors.StringExtractor;
import com.example.flow.Home;
import com.example.flow.R;
import com.example.flow.classes.Group;
import com.example.flow.classes.GroupExpense;
import com.example.flow.classes.UserExpense;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
public class HomeGroupFragment extends Fragment {
private final String TAG = this.getClass().getSimpleName();
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
private String mParam1;
private String mParam2;
ArrayList<GroupExpense> expense = new ArrayList<GroupExpense>();
public HomeGroupFragment() {
// Required empty public constructor
}
public static HomeGroupFragment newInstance(String param1, String param2) {
HomeGroupFragment fragment = new HomeGroupFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
Group group;
boolean status;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View RootView = inflater.inflate(R.layout.fragment_group, container, false);
/*
super.onCreate(savedInstanceState);
getActivity().setContentView(R.layout.fragment_group);
ConstraintLayout layout =getActivity().findViewById(R.id.groupLayout);
status = true;*/
//harcoded
UserExpense ux = new UserExpense(group.getUsers().get(2), 5.3);
UserExpense ux1 = new UserExpense(group.getUsers().get(3), 6.91);
ArrayList<UserExpense> uxs = new ArrayList<UserExpense>();
Collections.addAll(uxs, ux, ux1);
GroupExpense ex = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex1 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex2 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex3 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex4 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex5 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex6 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex7 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex8 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex9 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex10 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex11 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex12 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex13 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex14 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
GroupExpense ex15 = new GroupExpense(1, group.getUsers().get(1), "pitta", "voor te eten", 12.21, "13 oktober 2018", uxs);
Collections.addAll(expense, ex, ex1, ex2, ex3, ex4, ex5, ex6, ex7, ex8, ex9, ex10, ex11, ex12, ex13, ex14, ex15);
Intent intent = getActivity().getIntent();
group = Objects.requireNonNull(intent.getExtras()).getParcelable("group");
int id = intent.getIntExtra("group", -1);
TextView t = getActivity().findViewById(R.id.Groupname);
t.setText(group.getName());
t.setId(group.getGroupId());
setLayout();
return RootView;
}
public void changeToMember(View view)
{
Button member =getActivity().findViewById(R.id.member);
Button history =getActivity().findViewById(R.id.history);
if (status) {
member.setBackgroundResource(R.drawable.bottom_border_selected);
member.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
member.setTypeface(null, Typeface.BOLD);
member.setTextColor(Color.parseColor("#4799E8"));
history.setBackgroundResource(R.drawable.bottom_border);
history.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
history.setTypeface(null, Typeface.NORMAL);
history.setTextColor(Color.parseColor("#000000"));
status = false;
setLayout();
}
}
public void changeToHistory(View view)
{
Button member = getActivity().findViewById(R.id.member);
Button history =getActivity().findViewById(R.id.history);
if (!status) {
member.setBackgroundResource(R.drawable.bottom_border);
member.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
member.setTypeface(null, Typeface.NORMAL);
member.setTextColor(Color.parseColor("#000000"));
history.setBackgroundResource(R.drawable.bottom_border_selected);
history.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
history.setTypeface(null, Typeface.BOLD);
history.setTextColor(Color.parseColor("#4799E8"));
status = true;
setLayout();
}
}
public void setLayout()
{
ListView list = getActivity().findViewById(R.id.expenseList);
CustomAdapter ad = new CustomAdapter();
list.setAdapter(ad);
list.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
if (status) {
Intent intent = new Intent(getActivity().getApplicationContext(), GroupExpenseFragment.class);
intent.putExtra("expense", expense.get(position));
startActivity(intent);
} else {
Intent intent = new Intent(getActivity().getApplicationContext(), Home.class);
intent.putExtra("group", group.getUsers().get(position));
startActivity(intent);
}
}
});
}
public void leaveGroup(View view)
{
}
class CustomAdapter extends BaseAdapter
{
@Override
public int getCount()
{
return status ? expense.size() : group.getUsers().size();
}
@Override
public Object getItem(int position)
{
return position;
}
@Override
public long getItemId(int id)
{
return id;
}
public View getView(int i, View view, ViewGroup viewgroup)
{
if (status) {
view = getLayoutInflater().inflate(R.layout.group_expense_layout, null);
TextView user = view.findViewById(R.id.username);
TextView subject = view.findViewById(R.id.subject);
TextView amount = view.findViewById(R.id.expenseAmount);
user.setText(expense.get(i).getCreditor().getName());
subject.setText(expense.get(i).getName());
amount.setText(String.valueOf(expense.get(i).getAmount()));
} else {
view = getLayoutInflater().inflate(R.layout.group_member_layout, null);
TextView name = view.findViewById(R.id.nameMember);
TextView admin = view.findViewById(R.id.privilege);
TextView date = view.findViewById(R.id.date);
name.setText(group.getUsers().get(i).getName());
admin.setText("");
date.setText("");
}
return view;
}
}
}
fragment_group.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".displayClasses.GroupScreens.HomeGroupFragment">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/groupLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".displayClasses.GroupScreens.GroupFragment">
<TextView
android:id="@+id/Groupname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="@string/group_name"
android:textColor="#428EC4"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/member"
style="@style/selected"
android:layout_width="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif"
android:text="@string/history"
android:textAllCaps="false"
app:layout_constraintEnd_toStartOf="@+id/history"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/Groupname" />
<Button
android:id="@+id/history"
style="@style/unselected"
android:layout_width="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif"
android:text="@string/members"
android:textAllCaps="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/member"
app:layout_constraintTop_toBottomOf="@+id/Groupname" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/textView3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/history">
<ListView
android:id="@+id/expenseList"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/leave_group"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
group_expense_layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="25dp"
android:text="Username"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/username"
android:layout_marginStart="65dp"
android:layout_toEndOf="@+id/username"
android:text="Name" />
<TextView
android:id="@+id/expenseAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/username"
android:layout_alignParentEnd="true"
android:layout_marginStart="93dp"
android:layout_marginEnd="25dp"
android:layout_toEndOf="@+id/subject"
android:text="TextView" />
</RelativeLayout>
list :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.flow">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label=" "
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:icon,android:label">
<activity
android:theme="@style/AppTheme"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:theme="@style/AppTheme.NoActionBar"
android:name=".Home"
android:parentActivityName=".displayClasses.LoginScreens.Login">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".displayClasses.LoginScreens.Login" />
</activity>
<activity
android:theme="@style/AppTheme"
android:name=".displayClasses.LoginScreens.activity_signup" />
<activity
android:theme="@style/AppTheme"
android:name=".displayClasses.LoginScreens.Login" />
</application>
</manifest>
但据我所知,我不应该在我的 list 中实现 fragment 。那么我需要重写 Intent 语句吗?所以是的,我该怎么做才正确?我正在学习使用 Android Studio,非常感谢任何帮助。
最佳答案
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.flow/com.example.flow.displayClasses.GroupScreens.HomeGroupFragment}; have you declared this activity in your AndroidManifest.xml?
您是否在 list 中声明了 Activity ?
编辑:
这段代码在这里
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Intent intent = new Intent(getActivity().getApplicationContext(), HomeGroupFragment.class);
intent.putExtra("group", groups.get(position));
startActivity(intent);
}
这不是初始化 fragment 的方式。 startActivity() 用于启动 Activity 。这就是崩溃发生的原因。
要使用 fragment ,您必须进行 fragment 交易。在您将添加该 fragment 的 Activity 中创建一个 FrameLayout。更多信息 How do I add a Fragment to an Activity with a programmatically created content view
关于java - 无法从其他 fragment 加载 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53419337/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!