没有从片段转到另一个活动(ScheduleProf.java)

时间:2017-11-13 01:43:55

标签: java android android-tablayout

我的intent课程中有一个Riverfragment,然后它会将意图传递给scheduleprof课程。但它并没有进入scheduleprof类,尽管intent具有价值。错误是:这个

"InvocationTargetException  (id=103)    " and "exception    ActivityNotFoundException  (id=93)  
" and "11-13 08:41:16.849: E/AndroidRuntime(11076): FATAL EXCEPTION: main
"

ScheduleProf.java:

public class ScheduleProf extends Activity{
    String data = "";
    TableLayout tl;
    TableRow tr;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_schedprof);
        tl = (TableLayout) findViewById(R.id.maintable);
        Bundle get=getIntent().getExtras();
        final int profid=get.getInt("id"); //kunin ni course from fragment

    }
}

RiverFragment.java

public class RiverFragment extends Fragment{

    String data="";
    String course="",rooms="",sections="";
    Button myButton;
    Bundle extras1=new Bundle();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        Toast.makeText(getActivity(), data, Toast.LENGTH_LONG).show();
        // Retrieving the currently selected item number
        int position = getArguments().getInt("position");
        // List of rivers
        String[] rivers = getResources().getStringArray(R.array.rivers);

        //Bundle bundle1 = this.getArguments();
        int idprof =getArguments().getInt("id"); //kinuha ni fragment from bw
        // Creating view correspoding to the fragment
        View v = inflater.inflate(R.layout.welcome, container, false);
        if(rivers[position].equals("Courses"))
        {

            Intent intent = new Intent(getActivity(), Courseprof.class);
            extras1.putInt("id", idprof);
            intent.putExtras(extras1);//pasa sa course
            startActivity(intent);
        }
        else if(rivers[position].equals("Attendance"))
        {

            Intent intent = new Intent(getActivity(), ScheduleProf.class);
            extras1.putInt("id", idprof);
            intent.putExtras(extras1);//pasa sa ScheduleProf
            startActivity(intent);
        }

        // Getting reference to the TextView of the Fragment
        //TextView tv = (TextView) v.findViewById(R.id.tv_content);

        // Setting currently selected river name in the TextView
        //tv.setText(rivers[position]);     

        // Updating the action bar title
        getActivity().getActionBar().setTitle(rivers[position]);
        return v;
    }
}

activity_schedprof.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >



        <TableLayout
            android:id="@+id/maintable"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:stretchColumns="1,1,1" >
        </TableLayout>

</RelativeLayout>

0 个答案:

没有答案