コード例 #1
0
ファイル: CFragment.java プロジェクト: pixbit/android
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    /* Sets variable so that Preferences can be loaded and saved as in JavaScriptInterface */
    mContext = getActivity();

    try {
      /* Our PlistHandler now provides the parsed data to us. */
      //                this.entries = myHandler.getListOfRows();
      List<ParsedRow> bookmarkList = new ArrayList<ParsedRow>();
      int icon = android.R.drawable.ic_menu_delete;
      //			int icon = android.R.drawable.ic_menu_close_clear_cancel;

      /* Loads the Preference for Number of Bookmarks */
      String bmCount = LoadPreference("bmCount", "-1");
      Log.d(TAG, "----------------------------");
      Log.d(TAG, "bmCount: " + bmCount);
      for (int i = 0; i <= Integer.parseInt(bmCount); i++) {
        String bmTitle = LoadPreference("bmTitle" + i, "bmTitle");
        String bmScroll = LoadPreference("bmScroll" + i, "bmScroll");

        ParsedRow bmRow = new ParsedRow();
        bmRow.setTitle(bmTitle + "(" + bmScroll + ")" + " " + i + " of " + bmCount);
        bmRow.setView("3");
        bmRow.setScroll(bmScroll);
        bmRow.setIcon(icon);
        bmRow.setIndex(i);
        bookmarkList.add(bmRow);
      }

      ParsedRow row1 = new ParsedRow();
      row1.setTitle("Application Tutorial");
      row1.setView("5");
      row1.setScroll("0");
      bookmarkList.add(row1);

      ParsedRow row2 = new ParsedRow();
      row2.setTitle("Bookmark Tutorial");
      row2.setView("6");
      row2.setScroll("0");
      bookmarkList.add(row2);

      ParsedRow row3 = new ParsedRow();
      row3.setTitle("Navigation Tutorial");
      row3.setView("7");
      row3.setScroll("0");
      bookmarkList.add(row3);

      /* Set the result to be displayed in our GUI. */
      BookmarkAdapter adapter =
          new BookmarkAdapter(getActivity(), R.layout.bookmark_custom_row, bookmarkList, this);
      setListAdapter(adapter);

    } catch (Exception e) {
      /* Display any Error to the GUI. */
      Log.e(TAG, "XMLQueryError", e);
    }
  }
コード例 #2
0
ファイル: BookmarkAdapter.java プロジェクト: pixbit/android
    @Override
    public void onClick(View v) {
      Log.d(TAG, String.format("Position clicked = %d", this.position));
      Log.d(TAG, String.format("bmIndex clicked = %d", this.data.get(position).getIndex()));

      try {
        /* Our PlistHandler now provides the parsed data to us. */
        //                this.entries = myHandler.getListOfRows();
        List<ParsedRow> bookmarkList = new ArrayList<ParsedRow>();
        int icon = android.R.drawable.ic_menu_delete;
        //    			int icon = android.R.drawable.ic_menu_close_clear_cancel;
        String bmCount = LoadPreference("bmCount", "-1");

        /* Saves Bookmarks without the deleted one. */
        Log.d(TAG, "---------Delete--------");
        Log.d(TAG, "bmCount: " + bmCount);
        for (int i = 0; i <= Integer.parseInt(bmCount); i++) {
          String bmTitle = LoadPreference("bmTitle" + i, "bmTitle");
          String bmScroll = LoadPreference("bmScroll" + i, "bmScroll");

          if (i < this.position) {
            this.editBookmark(bmTitle, bmScroll, i);
          } else if (i == this.position) {
            Log.d(TAG, "editBookmark " + bmTitle + "[" + i + "] =" + bmScroll);
          } else if (i > this.position) {
            this.editBookmark(bmTitle, bmScroll, i - 1);
          } else {

          }
        }

        int theCount = Integer.parseInt(bmCount) - 1;
        Log.d(TAG, "theCount = " + theCount);
        SavePreference("bmCount", String.valueOf(theCount));

        /* Loads the Preference for Number of Bookmarks */
        Log.d(TAG, "----------Load----------");
        Log.d(TAG, "bmCount: " + bmCount);
        for (int i = 0; i <= Integer.parseInt(bmCount); i++) {
          String bmTitle = LoadPreference("bmTitle" + i, "bmTitle");
          String bmScroll = LoadPreference("bmScroll" + i, "bmScroll");

          ParsedRow bmRow = new ParsedRow();
          bmRow.setTitle(bmTitle + "(" + bmScroll + ")" + " " + i + " of " + bmCount);
          bmRow.setView("5");
          bmRow.setScroll(bmScroll);
          bmRow.setIcon(icon);
          bmRow.setIndex(i);
          bookmarkList.add(bmRow);
        }

        ParsedRow row1 = new ParsedRow();
        row1.setTitle("Application Tutorial");
        row1.setView("5");
        row1.setScroll("0");
        bookmarkList.add(row1);

        ParsedRow row2 = new ParsedRow();
        row2.setTitle("Bookmark Tutorial");
        row2.setView("6");
        row2.setScroll("0");
        bookmarkList.add(row2);

        ParsedRow row3 = new ParsedRow();
        row3.setTitle("Navigation Tutorial");
        row3.setView("7");
        row3.setScroll("0");
        bookmarkList.add(row3);

        /* Set the result to be displayed in our GUI. */
        BookmarkAdapter adapter =
            new BookmarkAdapter(
                this.context, R.layout.bookmark_custom_row, bookmarkList, this.frag);
        this.frag.setListAdapter(adapter);

      } catch (Exception e) {
        /* Display any Error to the GUI. */
        Log.e(TAG, "XMLQueryError", e);
      }

      //    		BookmarkAdapter.prevData.add(this.data);
      //    		this.nextData = this.data.get(position).getChildren();
      /* Set the result to be displayed in our GUI. */
      //    		BookmarkAdapter adapter = new BookmarkAdapter(this.context, R.layout.empsi_custom_row,
      // this.nextData, this.frag);
      //    		this.frag.setListAdapter(adapter);

      //    			EmpsiAdapter.prevTitle.add(this.data.get(position).getTitle());
      //    			((MainListActivity)
      // this.context).actionBar.setTitle(this.data.get(position).getTitle());
    }