I have a fragment and I am inflating it like below, but it is giving runtime error:
<TFOOT class='placer'>
<TR>
<TD>
<!-- empty here
-->
</TD>
</TR>
</TFOOT>
<TFOOT class='contenter'>
<TR>
<TD>
your long text or high image here
</TD>
</TR>
</TFOOT>
Its corresponding layout is:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View jobsView = inflater.inflate(R.layout.fragment_job_information, container, false);
textView = (TextView) jobsView.findViewById(R.id.textView);
if (jobInfo == null) {
EmployerHistory jobsQuery=new EmployerHistory();
jobInfo = jobsQuery.getJobInfo(employerName, position);
}
textView.setText(jobInfo.get("jobName").toString());
return jobsView;
}
Actually I am already on a fragment with listview and when user clicks on an element of listview that fragment needs to get changed by a new fragment, in my new fragment I have: l
<fragment 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" android:id="@+id/jobInfoFragment">
<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="com.example.ankit.job_depot.employer.view.JobInformation">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView2"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</fragment>
I am getting the following exception:
07-28 18:49:39.681 14474-14474/com.example.ankit.job_depot E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.ankit.job_depot, PID: 14474 android.view.InflateException: Binary XML file line #1: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763) at android.view.LayoutInflater.inflate(LayoutInflater.java:482) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at com.example.ankit.job_depot.employer.view.JobInformation.onCreateView(JobInformation.java:45) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
答案 0 :(得分:1)
I think your main Activity should extend FragmentActivity
// Need the IWorkbook for which your "worksheet" object belongs to.
IWorkbook workbook = worksheet.Workbook;
// This code assumes there is *always* a date (double) value in this cell. You may want
// to do some additional error checking to ensure B20 actually has a number in it.
// Otherwise the cast will give you issues.
DateTime dateReleased = workbook.NumberToDateTime((double)worksheet.Cells["B20"].Value);
fileInformation.DateReleased = dateReleased;
DateTime dateRequired = workbook.NumberToDateTime((double)worksheet.Cells["B21"].Value);
fileInformation.DateRequired = dateRequired