예제 #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    String db = getArguments().getString("db");

    Log.d("DEBUG", "Bookmarks Fragment : db=" + db);

    listingsDB = new ListingsDB(getActivity());
    listingsDB.open();
    Log.d("DEBUG", "create db");
  }
예제 #2
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    List<Listing> listings = listingsDB.getAllListings();

    adapter = new ListingAdapter(getActivity(), listings);

    ListView lvBookmarks = (ListView) getActivity().findViewById(R.id.lvBookmarks);
    lvBookmarks.setAdapter(adapter);

    lvBookmarks.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(
              AdapterView<?> adapterView, View parent, int position, long rowId) {
            Listing listing = (Listing) adapterView.getItemAtPosition(position);
            listingsDB.deleteListingById(listing.getId());
            adapter.remove(listing);
            Toast.makeText(getActivity(), "Bookmark deleted", Toast.LENGTH_SHORT).show();

            return false;
          }
        });

    lvBookmarks.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            Listing biz = (Listing) parent.getItemAtPosition(position);
            listener.onItemSelected(biz.getId());
          }
        });

    /*
     * 		lvBiz.setOnItemClickListener(new OnItemClickListener(){

    	@Override
    	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    		Listing biz = (Listing) parent.getItemAtPosition(position);
    		listener.onItemSelected(biz.getId());
    	}

    });
     *
     */

  }