コード例 #1
3
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.line_list);

    // Setup the list
    adapter = new IconAdapter<FileWrapper>(this, R.layout.line_list_item);
    ListView list = (ListView) findViewById(R.id.list);
    list.setAdapter(adapter);
    list.setOnItemClickListener(this);

    // Load Directory
    if (savedInstanceState != null) {
      backStack = savedInstanceState.getParcelableArrayList("BACKSTACK");
    }

    if (backStack == null || backStack.size() == 0) {
      backStack = new ArrayList<BackStackItem>();
      String startPath =
          (startDirectory == null || startDirectory.isEmpty())
              ? Environment.getExternalStorageDirectory().getPath()
              : startDirectory;
      backStack.add(new BackStackItem(startPath, false));
    }

    wrapFiles();
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  }
コード例 #2
0
 void invalidateView() {
   if (!myAndroidViews.isEmpty()) {
     myAndroidViews.clear();
     myListView.setAdapter(new ViewAdapter());
     myListView.invalidate();
   }
 }
コード例 #3
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
   final ListView view = (ListView) getTabHost().getCurrentView();
   final Bookmark bookmark = ((BookmarksAdapter) view.getAdapter()).getItem(position);
   switch (item.getItemId()) {
     case OPEN_ITEM_ID:
       gotoBookmark(bookmark);
       return true;
     case EDIT_ITEM_ID:
       final Intent intent = new Intent(this, BookmarkEditActivity.class);
       OrientationUtil.startActivityForResult(this, intent, 1);
       // TODO: implement
       return true;
     case DELETE_ITEM_ID:
       myCollection.deleteBookmark(bookmark);
       if (myThisBookAdapter != null) {
         myThisBookAdapter.remove(bookmark);
       }
       if (myAllBooksAdapter != null) {
         myAllBooksAdapter.remove(bookmark);
       }
       if (mySearchResultsAdapter != null) {
         mySearchResultsAdapter.remove(bookmark);
       }
       return true;
   }
   return super.onContextItemSelected(item);
 }
コード例 #4
0
  /** Called when the activity is first created */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "LoaderActivity created");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.content);

    // Instantiate custom adapter
    mAdapter = new LoaderAdapter();

    // Handle listview and assign adapter
    mListView = (ListView) findViewById(R.id.content_list_view);
    mListView.setAdapter(mAdapter);
    mListView.setVisibility(View.GONE);
    mListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
            selectItem(position);
            return true;
          }
        });

    mStatusLabel = (TextView) findViewById(R.id.content_status_label);
    mStatusLabel.setVisibility(View.VISIBLE);

    String userHash = NavigineApp.Settings.getString("user_hash", "");
    if (userHash.length() == 0) showUserHashDialog();
    else refreshMapList();
  }
コード例 #5
0
 BookmarksAdapter(ListView listView, List<Bookmark> bookmarks, boolean currentBook) {
   myBookmarks = bookmarks;
   myCurrentBook = currentBook;
   listView.setAdapter(this);
   listView.setOnItemClickListener(this);
   listView.setOnCreateContextMenuListener(this);
 }
コード例 #6
0
 public void mOnClick(View v) {
   switch (v.getId()) {
     case R.id.btn3:
       mItem.clear();
       for (int i = 1001; i <= 1003; i++) {
         mItem.add(Integer.toString(i));
       }
       mAdapter.notifyDataSetChanged();
       break;
     case R.id.btn10:
       mItem.clear();
       for (int i = 1001; i <= 1010; i++) {
         mItem.add(Integer.toString(i));
       }
       mAdapter.notifyDataSetChanged();
       break;
     case R.id.btnalways:
       mList.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
       break;
     case R.id.btnnever:
       mList.setOverScrollMode(View.OVER_SCROLL_NEVER);
       break;
     case R.id.btnifscroll:
       mList.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
       break;
   }
 }
コード例 #7
0
  public ListViewSwipeGesture(ListView listView, TouchCallbacks Callbacks, Activity context) {
    ViewConfiguration vc = ViewConfiguration.get(listView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mListView = listView;
    activity = context;
    tcallbacks = Callbacks;
    SwipeType = Double;
    GetResourcesValues();

    mListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(
              AdapterView<?> arg0,
              View arg1,
              int arg2,
              long arg3) { // Invokes OnClick Functionality

            if (!moptionsDisplay && DeltaX == 0.0) {
              tcallbacks.OnClickListView(temp_position);
            } else {
              if (old_mDownView != null && mDownView != old_mDownView) {
                ResetListItem(old_mDownView);
                old_mDownView = null;
                mDownView = null;
              }
            }
          }
        });
  }
コード例 #8
0
 void showSearchResultsTab(LinkedList<Bookmark> results) {
   if (mySearchResultsView == null) {
     mySearchResultsView = createTab("searchResults", R.id.search_results);
     new BookmarksAdapter(mySearchResultsView, mySearchResults, false);
   } else {
     mySearchResults.clear();
   }
   mySearchResults.addAll(results);
   mySearchResultsView.invalidateViews();
   mySearchResultsView.requestLayout();
   getTabHost().setCurrentTabByTag("searchResults");
 }
コード例 #9
0
 private void updateList() {
   View footerView = getFooterView();
   if (mListView.getFooterViewsCount() == 0) {
     mListView.addFooterView(footerView);
   }
   if (mSongAdapter == null) {
     mSongAdapter = new SongAdapter();
     mListView.setEmptyView(getEmptyView());
     mListView.setAdapter(mSongAdapter);
   } else {
     mSongAdapter.notifyDataSetChanged();
   }
 }
コード例 #10
0
  private void init() {
    setVerticalFadingEdgeEnabled(false);

    headerContainer =
        (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.ptr_header, null);
    header = (RelativeLayout) headerContainer.findViewById(R.id.ptr_id_header);
    text = (TextView) header.findViewById(R.id.ptr_id_text);
    lastUpdatedTextView = (TextView) header.findViewById(R.id.ptr_id_last_updated);
    image = (ImageView) header.findViewById(R.id.ptr_id_image);
    spinner = (ProgressBar) header.findViewById(R.id.ptr_id_spinner);

    pullToRefreshText = getContext().getString(R.string.ptr_pull_to_refresh);
    releaseToRefreshText = getContext().getString(R.string.ptr_release_to_refresh);
    refreshingText = getContext().getString(R.string.ptr_refreshing);
    lastUpdatedText = getContext().getString(R.string.ptr_last_updated);

    flipAnimation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
    flipAnimation.setFillAfter(true);

    reverseFlipAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
    reverseFlipAnimation.setFillAfter(true);

    addHeaderView(headerContainer);
    setState(State.PULL_TO_REFRESH);
    scrollbarEnabled = isVerticalScrollBarEnabled();

    ViewTreeObserver vto = header.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new PTROnGlobalLayoutListener());

    super.setOnItemClickListener(new PTROnItemClickListener());
    super.setOnItemLongClickListener(new PTROnItemLongClickListener());
  }
コード例 #11
0
  private void buildView() {
    ServiceAcctInfo[] tempList = new ServiceAcctInfo[accountList.size()];
    final ServiceAcctInfo[] acctList = accountList.toArray(tempList);
    AcctInfoAdapter adapter = new AcctInfoAdapter(this, acctList);
    setListAdapter(adapter);

    ListView lv = getListView();
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
            acctSelected(acctList[pos]);
          }
        });
  }
コード例 #12
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mListView = (ListView) mView.findViewById(R.id.lv);
    mListView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
              PullRightLayout.collapseAll();
            }
          }

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}
        });

    mStartScanView = (TextView) mView.findViewById(R.id.tv_start_scan);
    mStartScanView.setBackgroundColor(ThemeManager.with(getActivity()).getCurrentColor());
    mStartScanView.setOnClickListener(this);

    mPullLayout = (PullLayout) mView.findViewById(R.id.pull_layout);
    mPullLayout.addOnPullListener(this);
    if (mListener != null) {
      mPullLayout.addOnPullListener(mListener);
      mListener = null;
    }

    mIvScan = (ImageView) mView.findViewById(R.id.iv_scan);

    IntentFilter filter = new IntentFilter(ScanService.ACTION_SCAN_FINISH);
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter);
  }
コード例 #13
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    Boolean isDrawerOpen = mDrawerLayout.isDrawerOpen(Gravity.RIGHT);
    Boolean isMenuListFocused = false;
    if (mList != null) {
      isMenuListFocused = mList.hasFocus();
    }
    View view = this.getCurrentFocus();

    if (isDrawerOpen) {
      if (!view.getClass()
          .getName()
          .equalsIgnoreCase("com.android.internal.view.menu.ActionMenuItemView")) {
        mDrawerLayout.closeDrawers();
        mDrawerLayout.getChildAt(0).requestFocus();
      }
    } else {
      if (KeyEvent.KEYCODE_DPAD_UP == keyCode) {
        // action bar
        mDrawerLayout.getChildAt(1).requestFocus();
      } else if (KeyEvent.KEYCODE_DPAD_DOWN == keyCode) {
        // grid view
        mDrawerLayout.getChildAt(0).requestFocus();
      } else if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) {
      } else if (KeyEvent.KEYCODE_MENU == keyCode) {
        if (!mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
          mDrawerLayout.openDrawer(Gravity.RIGHT);
        } else {
          mDrawerLayout.closeDrawer(Gravity.RIGHT);
        }
      }
    }

    return super.onKeyDown(keyCode, event);
  }
コード例 #14
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Create a SQLite database holding event info
    DatabaseOpener dbopenhelper = new DatabaseOpener(this);
    db = dbopenhelper.getWritableDatabase();

    setContentView(R.layout.event_list);

    this.lv = (ListView) findViewById(R.id.eventListView);
    // Subclass CursorAdapter to read data from the database into the
    // ListView
    Cursor c =
        db.query(
            "event",
            new String[] {"_id", "isfavorite", "name", "starttime", "endtime"},
            null,
            null,
            null,
            null,
            "starttime asc");
    dbadapter = new EventListCursorAdapter(this, c, false);
    lv.setAdapter(dbadapter);
  }
コード例 #15
0
ファイル: GpsMainActivity.java プロジェクト: pari-m/gpslogger
  private void UploadToDropBox() {
    Utilities.LogDebug("GpsMainActivity.UploadToDropBox");

    final DropBoxHelper dropBoxHelper = new DropBoxHelper(getApplicationContext(), this);

    if (!dropBoxHelper.IsLinked()) {
      startActivity(new Intent("com.mendhak.gpslogger.DROPBOX_SETUP"));
      return;
    }

    final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger");

    if (gpxFolder.exists()) {

      String[] enumeratedFiles = gpxFolder.list();
      List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles));
      Collections.reverse(fileList);
      final String[] files = fileList.toArray(new String[fileList.size()]);

      final Dialog dialog = new Dialog(this);
      dialog.setTitle(R.string.dropbox_upload);
      dialog.setContentView(R.layout.filelist);
      ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles);

      thelist.setAdapter(
          new ArrayAdapter<String>(
              getApplicationContext(), android.R.layout.simple_list_item_single_choice, files));

      thelist.setOnItemClickListener(
          new OnItemClickListener() {

            public void onItemClick(AdapterView<?> av, View v, int index, long arg) {

              dialog.dismiss();
              String chosenFileName = files[index];
              Utilities.ShowProgress(
                  GpsMainActivity.this,
                  getString(R.string.dropbox_uploading),
                  getString(R.string.please_wait));
              dropBoxHelper.UploadFile(chosenFileName);
            }
          });
      dialog.show();
    } else {
      Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
    }
  }
コード例 #16
0
ファイル: Expr.java プロジェクト: thorntonrose/Expr
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    setContentView(R.layout.main);

    inputView = (EditText) findViewById(R.id.input_view);
    inputView.setOnEditorActionListener(this);

    listAdapter = new ArrayAdapter<String>(this, R.layout.row);
    listAdapter.setNotifyOnChange(true);

    resultsView = (ListView) this.findViewById(R.id.results_view);
    resultsView.setAdapter(listAdapter);
    resultsView.setOnItemClickListener(this);
  }
コード例 #17
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   if (months.isEmpty()) {
     throw new IllegalStateException(
         "Must have at least one month to display.  Did you forget to call init()?");
   }
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
コード例 #18
0
 /** Updates the display */
 protected void updateDisplay() {
   // Use BookAdapter to display the data
   if (borrowedBooks != null) {
     adapter = new BookAdapter(getActivity(), R.layout.item_book_image, borrowedBooks);
     list.setAdapter(adapter); // assign the adapter to the listview
   }
   swipe.setRefreshing(false);
 }
コード例 #19
0
  private void updateLoader() {
    if (NavigineApp.Navigation == null) return;

    // Log.d(TAG, String.format(Locale.ENGLISH, "Update loader: %d", mLoader));

    long timeNow = DateTimeUtils.currentTimeMillis();
    if (mLoader < 0) return;

    int status = LocationLoader.checkLocationLoader(mLoader);
    if (status < 100) {
      if ((Math.abs(timeNow - mLoaderTime) > LOADER_TIMEOUT / 3 && status == 0)
          || (Math.abs(timeNow - mLoaderTime) > LOADER_TIMEOUT)) {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText("Loading timeout!\nPlease, check your internet connection!");
        Log.d(TAG, String.format(Locale.ENGLISH, "Load stopped on timeout!"));
        LocationLoader.stopLocationLoader(mLoader);
        mLoader = -1;
      } else {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText(String.format(Locale.ENGLISH, "Loading content (%d%%)", status));
      }
    } else {
      Log.d(TAG, String.format(Locale.ENGLISH, "Load finished with result: %d", status));
      LocationLoader.stopLocationLoader(mLoader);
      mLoader = -1;

      if (status == 100) {
        parseMapsXml();
        if (mInfoList.isEmpty()) {
          mListView.setVisibility(View.GONE);
          mStatusLabel.setVisibility(View.VISIBLE);
          mStatusLabel.setText("No locations available");
        } else {
          mListView.setVisibility(View.VISIBLE);
          mStatusLabel.setVisibility(View.GONE);
        }
      } else {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText("Error loading!\nPlease, check your ID!");
      }
    }
  }
コード例 #20
0
 @Override
 public void onItemCheckedStateChanged(
     ActionMode mode, int position, long id, boolean checked) {
   // Get the total of checked items
   final int checkedCount = list.getCheckedItemCount();
   // Set the CAB title according to total checked items
   mode.setTitle(checkedCount + getString(R.string.selected_postfix));
   // Call to the toggle method of the adapter
   adapter.toggleSelection(position);
 }
コード例 #21
0
  @Override
  protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    super.onScrollChanged(l, t, oldl, oldt);

    if (!hasResetHeader) {
      if (measuredHeaderHeight > 0 && state != State.REFRESHING) {
        setHeaderPadding(-measuredHeaderHeight);
      }

      hasResetHeader = true;
    }
  }
コード例 #22
0
ファイル: FolderList.java プロジェクト: fernandocoello/k-9
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.folder_list);
    mListView = getListView();
    mListView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET);
    mListView.setLongClickable(true);
    mListView.setFastScrollEnabled(true);
    mListView.setScrollingCacheEnabled(true);
    mListView.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            onOpenFolder(((FolderInfoHolder) mAdapter.getItem(id)).name);
          }
        });
    registerForContextMenu(mListView);

    mListView.setSaveEnabled(true);

    mInflater = getLayoutInflater();

    onNewIntent(getIntent());

    context = this;
  }
コード例 #23
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.c09_overscroll);

    for (int i = 1001; i <= 1003; i++) {
      mItem.add(Integer.toString(i));
    }

    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mItem);

    mList = (ListView) findViewById(R.id.list);
    mList.setAdapter(mAdapter);
  }
コード例 #24
0
 private void GetResourcesValues() {
   mAnimationTime =
       mListView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime);
   HalfColor = RangeOneColor; // Green
   FullColor = activity.getResources().getString(R.string.str_red); // Orange
   HalfText = activity.getResources().getString(R.string.basic_action_1);
   HalfTextFinal = activity.getResources().getString(R.string.basic_action_1);
   FullText = activity.getResources().getString(R.string.basic_action_2);
   FullTextFinal = activity.getResources().getString(R.string.basic_action_2);
   //        HalfDrawable        =   activity.getResources().getDrawable( R.drawable.rating_good );
   //        FullDrawable        =
   // activity.getResources().getDrawable(R.drawable.content_discard);
 }
コード例 #25
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Create layout and drawer
    setContentView(R.layout.activity_main);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // Set listeners
    mDrawerList.setAdapter(new DrawerListArrayAdapter(this, mFragmentList));
    mDrawerList.setOnItemClickListener(this);

    // Drawer layout
    mDrawerLayout = ((DrawerLayout) findViewById(R.id.drawer_layout));

    mTabletLandscape = mDrawerLayout == null;

    if (!mTabletLandscape) {
      // Change actionbar toggle icon
      mDrawerToggle =
          new ActionBarDrawerToggle(
              this, /* host Activity */
              mDrawerLayout, /* DrawerLayout object */
              R.drawable.ic_navigation_drawer, /* nav drawer icon to replace 'Up' caret */
              R.string.open_drawer, /* "open drawer" description */
              R.string.close_drawer /* "close drawer" description */);

      mDrawerLayout.setDrawerListener(mDrawerToggle);
      getActionBar().setDisplayHomeAsUpEnabled(true);
      getActionBar().setHomeButtonEnabled(true);
    }

    // Set default view
    if (savedInstanceState == null) {
      switchContent(new OverviewFragment(), false);
      setTitle(mFragmentList[0]);
    }
  }
コード例 #26
0
  public void setMeatToppingsView() {

    ListView list = (ListView) findViewById(R.id.meatToppingsView);
    String[] meat = {"Pepperoni", "Chicken", "Ground Beef", "Anchovies", "Bacon Bits"};
    List<String> meatList = Arrays.asList(meat);
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, meatList);
    list.setAdapter(adapter);
    list.setClickable(true);
    list.setChoiceMode(list.CHOICE_MODE_MULTIPLE);
    list.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CheckedTextView item = (CheckedTextView) view;
            if (item.isChecked()) {
              numMeatToppings++;
            } else {
              numMeatToppings--;
            }
          }
        });
  }
コード例 #27
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);

    // Instantiate lists
    tasks = new ArrayList<>();
    tempBookList = new ArrayList<>();
    swipe = new SwipeRefreshLayout(getActivity());

    // Instantiate listview
    list = new ListView(getActivity());

    // Initiate progressbar for loading
    pb = new ProgressBar(getActivity()); // Init the progressbar
    pb.setId(1); // Give pb an id
    pb.setVisibility(View.INVISIBLE); // Set progressbar visibility

    // Set details list
    list.setBackgroundColor(Color.WHITE);
    list.setMultiChoiceModeListener(multiChoiceHandler);
    list.setOnItemClickListener(onItemClickHandler);
    list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);

    swipe.setOnRefreshListener(refreshListener);

    try {
      requestData(BookshelfConstants.CONNECTION_URI);
    } catch (JSONException e) {
      e.printStackTrace();
    }

    swipe.addView(list);

    return swipe;
  }
コード例 #28
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case CONTEXT_DELETE_TAG:
       AdapterView.AdapterContextMenuInfo menuInfo =
           (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
       db.deleteTag(menuInfo.id);
       ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
       Cursor listItem = (Cursor) lv.getItemAtPosition(menuInfo.position);
       String tagName = listItem.getString(1);
       ((TagViewListAdaptor) lv.getAdapter()).refreshData();
       Toast.makeText(SBActivity.this, "Tag '" + tagName + "' deleted.", Toast.LENGTH_SHORT)
           .show();
       return true;
     case CONTEXT_VIEW_NOTES:
       AdapterView.AdapterContextMenuInfo menuInfo2 =
           (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
       Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery);
       g.setAdapter(new NoteGalleryImageAdaptor(SBActivity.this, db.findNotesByTag(menuInfo2.id)));
       setContentView(viewNoteGallery);
     default:
       return super.onContextItemSelected(item);
   }
 }
コード例 #29
0
  private void selectItem(int position) {
    // update the main content by replacing fragments
    //        Fragment fragment = new PlanetFragment();
    //        Bundle args = new Bundle();
    //        args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
    //        fragment.setArguments(args);
    //
    //        android.app.FragmentManager fragmentManager = getFragmentManager();
    //        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    // update selected item and title, then close the drawer
    mDrawerList.setItemChecked(position, true);
    //        setTitle(mPlanetTitles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
  }
コード例 #30
0
 private void invalidateAllViews() {
   myThisBookView.invalidateViews();
   myThisBookView.requestLayout();
   myAllBooksView.invalidateViews();
   myAllBooksView.requestLayout();
   if (mySearchResultsView != null) {
     mySearchResultsView.invalidateViews();
     mySearchResultsView.requestLayout();
   }
 }