Back to project page ProjectStudio.
The source code is released under:
Apache License
If you think the Android project ProjectStudio listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package fragments; /*from ww w . j a v a 2s .c o m*/ import android.database.Cursor; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.TextView; import com.example.uniutilproject.R; import java.sql.SQLException; import DB_Provider.CourseDataSource; import adapters.ExamsPassedCardAdapter; /** * Created by desmond on 1/20/14. * */ public class ExamsPassedFragment extends Fragment { private TextView exams_passed; private TextView exams_average; private ListView passed_exams_list; private CourseDataSource dataSource; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.exams_passedview, container, false); //CALL DATABASE dataSource = new CourseDataSource(getActivity()); try { dataSource.open(); } catch (SQLException e) { e.printStackTrace(); } //INFLATE VIEWS HERE if (view != null) { exams_passed = (TextView) view.findViewById(R.id.exams_passed); exams_average = (TextView) view.findViewById(R.id.exams_average); passed_exams_list = (ListView) view.findViewById(R.id.passed_exams_listview); } new android.os.Handler().post(new Runnable() { @Override public void run() { final Cursor cursor = dataSource.getPassedExams(); ExamsPassedCardAdapter adapter = new ExamsPassedCardAdapter(getActivity(), cursor, true); passed_exams_list.setAdapter(adapter); adapter.notifyDataSetChanged(); //GET NUMBER OF PASSED EXAMS int exam_count = dataSource.getPassedExamsCount(); exams_passed.setText(exam_count + ""); //GET AVERAGE OF PASSED EXAMS float exams_avg = dataSource.getPassedExamsAverge(); exams_average.setText(exams_avg + ""); } }); dataSource.close(); return view; } @Override public void onResume() { try { dataSource.open(); } catch (SQLException e) { e.printStackTrace(); } super.onResume(); } @Override public void onPause() { dataSource.close(); super.onPause(); } }