@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_search_list); list = getListView(); backBtn = (ImageButton) findViewById(R.id.backBtn); priceBtn = (Button) findViewById(R.id.orderByPriceBtn); timeBtn = (Button) findViewById(R.id.orderByTimeBtn); tvnomatchfound = (TextView) findViewById(R.id.tvnomatchfound); backBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub new HomeFragment().refresh(); shared.fromString = ""; shared.toString = ""; shared.through1String = ""; shared.fromPrice = ""; shared.toPrice = ""; shared.departureDate = ""; shared.day = ""; if (shared.through2String.length() > 0) { shared.through2String = ""; } if (shared.through3String.length() > 0) { shared.through3String = ""; } if (HomeFragment.throughPath2 != null) { HomeFragment.throughPath2.setText(""); HomeFragment.throughPath2.setEnabled(true); HomeFragment.throughPath2.setFocusableInTouchMode(true); HomeFragment.throughPath2.setError(null); } if (HomeFragment.throughPath3 != null) { HomeFragment.throughPath3.setText(""); HomeFragment.throughPath3.setEnabled(true); HomeFragment.throughPath3.setFocusableInTouchMode(true); HomeFragment.throughPath3.setError(null); } HomeActivity.mFrameLayout.setVisibility(View.GONE); finish(); } }); priceBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub @SuppressWarnings("unused") String arrange = selectQuery("cost", true); Toast.makeText( getApplicationContext(), "Transports ordered in price", Toast.LENGTH_SHORT) .show(); if (price_clicked == false) { price_clicked = true; time_clicked = false; cur = dbHelper.getData(myquery + " order by transportation.cost" + " asc"); adpater1.cursor = cur; System.out.println("arrange"); adpater1.notifyDataSetChanged(); } } }); timeBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub @SuppressWarnings("unused") String arrange = selectQuery("cost", true); Toast.makeText( getApplicationContext(), "Transports ordered in time", Toast.LENGTH_SHORT) .show(); if (time_clicked == false) { price_clicked = false; time_clicked = true; cur = dbHelper.getData(myquery + " order by transportation.interval" + " asc"); adpater1.cursor = cur; adpater1.notifyDataSetChanged(); } } }); dbHelper = new MySQLiteHelper(getApplicationContext()); if (shared.vehicle != "all") v_id = dbHelper.getIdForName(dbHelper.TAG_TYPE, shared.vehicle); try { myquery = selectQuery("cost", true); } catch (Exception e) { } cur = dbHelper.getData(myquery); try { if (cur.getCount() == 0) { // here cur is null so we will have to check if direct path is // possible without other search criteria before giving // suggestions myquery = selectQuery("cost", false); Cursor cur1 = dbHelper.getData(myquery); if (cur1.getCount() == 0) { head = true; Intent intentnomatch = new Intent(getApplicationContext(), NoMatchFound.class); startActivityForResult(intentnomatch, 2); } else { // -------------------- list.setVisibility(View.GONE); tvnomatchfound.setVisibility(View.VISIBLE); } } } catch (Exception e) { } adpater1 = new MyArrayAdapter1(getApplicationContext(), cur); setListAdapter(adpater1); new HomeFragment().refresh(); }