のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

BackStackRecord.getBreadCrumbTitle

    235     void updateCrumbs() {
    236         FragmentManager fm = mActivity.getFragmentManager();
    237         int numEntries = fm.getBackStackEntryCount();
    238         int numPreEntries = getPreEntryCount();
    239         int numViews = mContainer.getChildCount();
    240         for (int i = 0; i < numEntries + numPreEntries; i++) {
    241             BackStackEntry bse = i < numPreEntries
    242                     ? getPreEntry(i)
    243                     : fm.getBackStackEntryAt(i - numPreEntries);
    244             if (i < numViews) {
    245                 View v = mContainer.getChildAt(i);
    246                 Object tag = v.getTag();
    247                 if (tag != bse) {
    248                     for (int j = i; j < numViews; j++) {
    249                         mContainer.removeViewAt(i);
    250                     }
    251                     numViews = i;
    252                 }
    253             }
    254             if (i >= numViews) {
    255                 final View item = mInflater.inflate(
    256                         com.android.internal.R.layout.fragment_bread_crumb_item,
    257                         this, false);
    258                 final TextView text = (TextView) item.findViewById(com.android.internal.R.id.title);
    259                 text.setText(bse.getBreadCrumbTitle()); <=============================
    260                 text.setTag(bse);
    261                 if (i == 0) {
    262                     item.findViewById(com.android.internal.R.id.left_icon).setVisibility(View.GONE);
    263                 }
    264                 mContainer.addView(item);
    265                 text.setOnClickListener(mOnClickListener);
    266             }
    267         }
    268         int viewI = numEntries + numPreEntries;
    269         numViews = mContainer.getChildCount();
    270         while (numViews > viewI) {
    271             mContainer.removeViewAt(numViews - 1);
    272             numViews--;
    273         }
    274         // Adjust the visibility and availability of the bread crumbs and divider
    275         for (int i = 0; i < numViews; i++) {
    276             final View child = mContainer.getChildAt(i);
    277             // Disable the last one
    278             child.findViewById(com.android.internal.R.id.title).setEnabled(i < numViews - 1);
    279             if (mMaxVisible > 0) {
    280                 // Make only the last mMaxVisible crumbs visible
    281                 child.setVisibility(i < numViews - mMaxVisible ? View.GONE : View.VISIBLE);
    282                 final View leftIcon = child.findViewById(com.android.internal.R.id.left_icon);
    283                 // Remove the divider for all but the last mMaxVisible - 1
    284                 leftIcon.setVisibility(i > numViews - mMaxVisible && i != 0 ? View.VISIBLE
    285                         : View.GONE);
    286             }
    287         }
    288     }
    307     public CharSequence getBreadCrumbTitle() {
    308         if (mBreadCrumbTitleRes != 0) {
    309             return mManager.mActivity.getText(mBreadCrumbTitleRes);
    310         }
    311         return mBreadCrumbTitleText;
    312     }