コード例 #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
  /** 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();
  }
コード例 #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
 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;
   }
 }
コード例 #5
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]);
          }
        });
  }
コード例 #6
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);
  }
コード例 #7
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);
  }
コード例 #8
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!");
      }
    }
  }
コード例 #9
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);
  }
コード例 #10
0
ファイル: NotesTest.java プロジェクト: thorntonrose/Notes
 public void testStart_Files() {
   ds.writeNote("Note 1", "test");
   start();
   assertTrue("listView.isShown == false", listView.isShown());
   assertEquals("count:", 1, listAdapter.getCount());
 }
コード例 #11
0
ファイル: NotesTest.java プロジェクト: thorntonrose/Notes
 public void testStart_NoFiles() {
   start();
   assertTrue("listView.isShown == false", listView.isShown());
   assertEquals("count:", 0, listAdapter.getCount());
 }
コード例 #12
0
ファイル: NotesTest.java プロジェクト: thorntonrose/Notes
 public void start() {
   notes = getActivity();
   listView = notes.getListView();
   listAdapter = listView.getAdapter();
 }
コード例 #13
0
 BookmarksAdapter(ListView listView, boolean showAddBookmarkItem) {
   myShowAddBookmarkItem = showAddBookmarkItem;
   listView.setAdapter(this);
   listView.setOnItemClickListener(this);
   listView.setOnCreateContextMenuListener(this);
 }