Java Code Examples for android.widget.listview#setEmptyView()

The following examples show how to use android.widget.listview#setEmptyView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlarmClockActivity.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostExecute(AlarmClockAdapter result)
{
    if (result != null)
    {
        ListView alarmList = alarmListRef.get();
        if (alarmList != null)
        {
            alarmList.setAdapter(result);
            View emptyView = emptyViewRef.get();
            if (emptyView != null) {
                alarmList.setEmptyView(emptyView);
            }
        }

        if (taskListener != null) {
            taskListener.onFinished(result);
        }
    }
}
 
Example 2
Source File: SingleCategoryPreferences.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    addPreferencesFromResource(R.xml.website_preferences);
    ListView listView = (ListView) getView().findViewById(android.R.id.list);
    mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
    listView.setEmptyView(mEmptyView);
    listView.setDivider(null);

    mClearButton = (Button) getView().findViewById(R.id.clear_button);
    if (mClearButton != null) {
        mClearButton.setOnClickListener(this);
    }

    String title = getArguments().getString(EXTRA_TITLE);
    if (title != null) getActivity().setTitle(title);

    configureGlobalToggles();

    setHasOptionsMenu(true);

    super.onActivityCreated(savedInstanceState);
}
 
Example 3
Source File: OngoingNotifPreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBindDialogView(View view) {
    mListView = (ListView) view.findViewById(R.id.icon_list);
    mListView.setOnItemClickListener(this);
    mListView.setEmptyView(view.findViewById(R.id.info_list_empty));

    mBtnResetList = (Button) view.findViewById(R.id.btnReset);
    mBtnResetList.setOnClickListener(this);

    mDescription = (TextView) view.findViewById(R.id.description);
    mDivider = (View) view.findViewById(R.id.divider);

    super.onBindView(view);

    setData();
}
 
Example 4
Source File: ListActivity.java    From PreferenceFragment with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the screen state (current list and other views) when the
 * content changes.
 *
 * @see Activity#onContentChanged()
 */
public void onSupportContentChanged() {
    super.onSupportContentChanged();
    View emptyView = findViewById(android.R.id.empty);
    mList = (ListView)findViewById(android.R.id.list);
    if (mList == null) {
        throw new RuntimeException(
                "Your content must have a ListView whose id attribute is " +
                "'android.R.id.list'");
    }
    if (emptyView != null) {
        mList.setEmptyView(emptyView);
    }
    mList.setOnItemClickListener(mOnClickListener);
    if (mFinishedStart) {
        setListAdapter(mAdapter);
    }
    mHandler.post(mRequestFocus);
    mFinishedStart = true;
}
 
Example 5
Source File: MainActivity.java    From SwipeRefreshLayout-ListViewExample with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // SwipeRefreshLayout
    mListViewContainer = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout_listView);
    mEmptyViewContainer = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout_emptyView);

    // Configure SwipeRefreshLayout
    onCreateSwipeToRefresh(mListViewContainer);
    onCreateSwipeToRefresh(mEmptyViewContainer);

    // Adapter
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
    mAdapter.addAll(new Vector(Arrays.asList(getResources().getStringArray(R.array.kings))));

    // ListView
    ListView listView = (ListView) findViewById(R.id.listView);
    listView.setEmptyView(mEmptyViewContainer);
    listView.setAdapter(mAdapter);

}
 
Example 6
Source File: PickerView.java    From PickerView with Apache License 2.0 6 votes vote down vote up
private void initView() {
    pickerTitleName = (TextView) view.findViewById(R.id.pickerTitleName);
    pickerConfirm = (TextView) view.findViewById(R.id.pickerConfirm);
    groupSelect = (RadioGroup) view.findViewById(R.id.groupSelect);
    mTextFirst = (RadioButton) view.findViewById(R.id.mTextFirst);
    mTextSecond = (RadioButton) view.findViewById(R.id.mTextSecond);
    mTextThird = (RadioButton) view.findViewById(R.id.mTextThird);
    mTextFourth = (RadioButton) view.findViewById(R.id.mTextFourth);
    pickerList = (ListView) view.findViewById(R.id.pickerList);
    emptyView = (TextView) view.findViewById(R.id.empty_data_hints);
    pickerList.setEmptyView(view.findViewById(R.id.picker_list_empty_data));
    mTextFirst.setOnClickListener(this);
    mTextSecond.setOnClickListener(this);
    mTextThird.setOnClickListener(this);
    pickerConfirm.setOnClickListener(this);
    if (!TextUtils.isEmpty(pickerData.getPickerTitleName())){
        pickerTitleName.setText(pickerData.getPickerTitleName());
    }
}
 
Example 7
Source File: FragmentListActivity.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the screen state (current list and other views) when the content
 * changes.
 *
 * @see Activity#onContentChanged()
 */
@Override
public void onContentChanged() {
    super.onContentChanged();

    // changed references from com.android.internal.R to android.R.*
    View emptyView = findViewById(android.R.id.empty);
    mList = (ListView) findViewById(android.R.id.list);

    if (mList == null) {
        throw new RuntimeException("Your content must have a ListView whose id attribute is " + "'android.R.id.list'");
    }
    if (emptyView != null) {
        mList.setEmptyView(emptyView);
    }
    mList.setOnItemClickListener(mOnClickListener);
    if (mFinishedStart) {
        setListAdapter(mAdapter);
    }
    mHandler.post(mRequestFocus);
    mFinishedStart = true;
}
 
Example 8
Source File: SingleCategoryPreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    addPreferencesFromResource(R.xml.website_preferences);
    ListView listView = (ListView) getView().findViewById(android.R.id.list);
    mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
    listView.setEmptyView(mEmptyView);
    listView.setDivider(null);

    mClearButton = (Button) getView().findViewById(R.id.clear_button);
    if (mClearButton != null) {
        mClearButton.setOnClickListener(this);
    }

    String title = getArguments().getString(EXTRA_TITLE);
    if (title != null) getActivity().setTitle(title);

    configureGlobalToggles();

    setHasOptionsMenu(true);

    super.onActivityCreated(savedInstanceState);
}
 
Example 9
Source File: StarkSpinner.java    From SSForms with GNU General Public License v3.0 6 votes vote down vote up
public StarkSpinner(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mContext = context;
    getAttributeSet(attrs, defStyleAttr, defStyleRes);

    final LayoutInflater factory = LayoutInflater.from(context);
    factory.inflate(R.layout.view_stark_spinner, this, true);

    mSpinnerListContainer = (LinearLayout) factory.inflate(R.layout.view_list, this, false);
    mSpinnerListView = (ListView) mSpinnerListContainer.findViewById(R.id.LstVw_SpinnerListView);
    if (mListItemDivider != null) {
        mSpinnerListView.setDivider(mListItemDivider);
        mSpinnerListView.setDividerHeight(mListDividerSize);
    }
    mEmptyTextView = (TextView) mSpinnerListContainer.findViewById(R.id.TxtVw_EmptyText);
    mSpinnerListView.setEmptyView(mEmptyTextView);
}
 
Example 10
Source File: ListActivity.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the screen state (current list and other views) when the
 * content changes.
 *
 * @see Activity#onContentChanged()
 */
@Override
public void onContentChanged() {
    super.onContentChanged();
    View emptyView = findViewById(com.android.internal.R.id.empty);
    mList = (ListView)findViewById(com.android.internal.R.id.list);
    if (mList == null) {
        throw new RuntimeException(
                "Your content must have a ListView whose id attribute is " +
                "'android.R.id.list'");
    }
    if (emptyView != null) {
        mList.setEmptyView(emptyView);
    }
    mList.setOnItemClickListener(mOnClickListener);
    if (mFinishedStart) {
        setListAdapter(mAdapter);
    }
    mHandler.post(mRequestFocus);
    mFinishedStart = true;
}
 
Example 11
Source File: DiscoveryListActivity.java    From SI with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.discovery_result);

    Intent intent = getIntent();
    foundDeviceInfo = (FoundDeviceInfo)intent.getSerializableExtra("foundDeviceInfo");

    setCustomActionbar();
    image_details = new ArrayList<FoundItem>();

    for(FoundItem foundItem : foundDeviceInfo.getDeviceList()) {
        image_details.add(foundItem);
    }

    final View empty = findViewById(R.id.list_empty_1);
    final ListView lv1 = (ListView) findViewById(R.id.discovery_list);
    customListAdapter = new CustomListAdapter(this, image_details);

    if(image_details.isEmpty()) {
        lv1.setEmptyView(empty);
    } else {
        lv1.setAdapter(customListAdapter);
        empty.setVisibility(View.GONE);
    }

}
 
Example 12
Source File: BookmarkFragment.java    From QuranAndroid with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Init views in the fragment
 * @param rootView Fragment view
 */
private void init(View rootView) {
    bookmarks = new ArrayList<Bookmark>();
    adapter = new BookmarksShowAdapter(getActivity() , bookmarks);
    bookmarkList = (ListView) rootView.findViewById(R.id.listView);
    bookmarkList.setEmptyView(rootView.findViewById(R.id.listView1));
    bookmarkList.setAdapter(adapter);
    bookmarkList.setOnItemClickListener(this);
    new loadBookmarks().execute();
}
 
Example 13
Source File: ManageCNLActivity.java    From 600SeriesAndroidUploader with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manage_cnl);

    Toolbar toolbar = findViewById(R.id.toolbar);

    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeAsUpIndicator(
                new IconicsDrawable(this)
                        .icon(GoogleMaterial.Icon.gmd_arrow_back)
                        .color(Color.WHITE)
                        .sizeDp(24)
        );
        getSupportActionBar().setElevation(0);
        getSupportActionBar().setTitle(R.string.manage_cnl__title);
    }

    mRealm = Realm.getDefaultInstance();

    //generate list
    ArrayList<ContourNextLinkInfo> list = new ArrayList<>();

    list.addAll(mRealm.where(ContourNextLinkInfo.class).findAll());

    //instantiate custom adapter
    CNLAdapter adapter = new CNLAdapter(list, this);

    //handle listview and assign adapter
    ListView lView = findViewById(R.id.cnl_list);
    lView.addHeaderView(getLayoutInflater().inflate(R.layout.manage_cnl_listview_header, null));
    lView.setEmptyView(findViewById(R.id.manage_cnl_listview_empty)); //getLayoutInflater().inflate(R.layout.manage_cnl_listview_empty, null));
    lView.setAdapter(adapter);
}
 
Example 14
Source File: TranslationsActivity.java    From QuranAndroid with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Function to init activity view
 */
private void init() {

    //init views
    adapter = new TranslationAdapter(this);
    translationManagmentList = (ListView) findViewById(R.id.download);
    translationManagmentList.setOnItemClickListener(this);
    translationManagmentList.setTextFilterEnabled(true);
    translationManagmentList.setEmptyView(findViewById(R.id.progressBar3));
    translationManagmentList.setAdapter(adapter);

    //async thread to load translations
    new TafaseerLists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 15
Source File: HistoryActivity.java    From LLApp with Apache License 2.0 5 votes vote down vote up
protected <T extends View> T setEmptyView(ListView listView) {
    TextView emptyView = new TextView(this);
    emptyView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    emptyView.setText("暂无数据!");
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    emptyView.setVisibility(View.GONE);
    ((ViewGroup) listView.getParent()).addView(emptyView);
    listView.setEmptyView(emptyView);
    return (T) emptyView;
}
 
Example 16
Source File: ServerListActivity.java    From padland with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_server_list);
    mAdapter = new ServerListAdapter(ServerListActivity.this, R.layout.serverlist_item);
    listView = (ListView) findViewById(R.id.listView);
    if (listView != null) {
        listView.setChoiceMode(choiceMode);
        listView.setEmptyView(findViewById(android.R.id.empty));
        listView.setAdapter(mAdapter);
        this._setListViewEvents();
    }
}
 
Example 17
Source File: ListUrlsActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.physical_web_list_urls_activity);

    initSharedPreferences();

    mAdapter = new NearbyUrlsAdapter(this);

    View emptyView = findViewById(R.id.physical_web_empty);
    mListView = (ListView) findViewById(R.id.physical_web_urls_list);
    mListView.setEmptyView(emptyView);
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(this);

    mEmptyListText = (TextView) findViewById(R.id.physical_web_empty_list_text);

    mScanningImageView = (ImageView) findViewById(R.id.physical_web_logo);

    mSwipeRefreshWidget =
            (SwipeRefreshWidget) findViewById(R.id.physical_web_swipe_refresh_widget);
    mSwipeRefreshWidget.setOnRefreshListener(this);

    mBottomBar = findViewById(R.id.physical_web_bottom_bar);

    int shadowColor = ApiCompatibilityUtils.getColor(getResources(),
            R.color.bottom_bar_shadow_color);
    FadingShadowView shadow =
            (FadingShadowView) findViewById(R.id.physical_web_bottom_bar_shadow);
    shadow.init(shadowColor, FadingShadow.POSITION_BOTTOM);

    View bottomBarClose = (View) findViewById(R.id.physical_web_bottom_bar_close);
    bottomBarClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hideBottomBar();
        }
    });

    mPwsClient = new PwsClientImpl(this);
    int referer = getIntent().getIntExtra(REFERER_KEY, 0);
    if (savedInstanceState == null) {  // Ensure this is a newly-created activity.
        PhysicalWebUma.onActivityReferral(this, referer);
    }
    mIsInitialDisplayRecorded = false;
    mIsRefreshing = false;
    mIsRefreshUserInitiated = false;
    mPhysicalWebBleClient =
        PhysicalWebBleClient.getInstance((ChromeApplication) getApplicationContext());
}
 
Example 18
Source File: PhotoAlbumPickerActivity.java    From KrGallery with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public View createView(Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
    // actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackText(context.getString(R.string.Cancel));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == 1) {
                if (delegate != null) {
                    finishFragment(false);
                    delegate.startPhotoSelectActivity();
                }
            } else if (id == item_photos) {
                refreshShowPic();//刷新照片目录
            } else if (id == item_video) {
                refreshShowVedio();//刷新录像目录
            }
        }
    });


    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(DarkTheme ? 0xff000000 : 0xffffffff);
    //==============videos pick====================
    int res = !singlePhoto && filterMimeTypes.length > 0 ? R.string.PickerVideo : R.string.Album;
    actionBar.setTitle(context.getString(res));
    selectedMode = filterMimeTypes.length > 0 ? 1 : selectedMode;
    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4),
            AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView
            .getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    // layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(R.string.NoPhotos);
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);


    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
        progressView.setVisibility(View.VISIBLE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    return fragmentView;
}
 
Example 19
Source File: DocumentSelectActivity.java    From Yahala-Messenger with MIT License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (!receiverRegistered) {
        receiverRegistered = true;
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
        filter.addAction(Intent.ACTION_MEDIA_CHECKING);
        filter.addAction(Intent.ACTION_MEDIA_EJECT);
        filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
        filter.addAction(Intent.ACTION_MEDIA_NOFS);
        filter.addAction(Intent.ACTION_MEDIA_REMOVED);
        filter.addAction(Intent.ACTION_MEDIA_SHARED);
        filter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE);
        filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
        filter.addDataScheme("file");
        getParentActivity().registerReceiver(receiver, filter);
    }


    if (fragmentView == null) {
        fragmentView = inflater.inflate(R.layout.document_select_layout, container, false);
        fragmentView.setPadding(0, (int) getResources().getDimension(R.dimen.actionbar_height), 0, 0);
        listAdapter = new ListAdapter(parentActivity);
        emptyView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
        listView = (ListView) fragmentView.findViewById(R.id.listView);
        listView.setEmptyView(emptyView);
        listView.setAdapter(listAdapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                ListItem item = items.get(i);
                File file = item.file;
                if (file.isDirectory()) {
                    HistoryEntry he = new HistoryEntry();
                    he.scrollItem = listView.getFirstVisiblePosition();
                    he.scrollOffset = listView.getChildAt(0).getTop();
                    he.dir = currentDir;
                    ActionBar actionBar = parentActivity.getSupportActionBar();
                    he.title = actionBar.getTitle().toString();
                    if (!listFiles(file)) {
                        return;
                    }
                    history.add(he);
                    actionBar.setTitle(item.title);
                    listView.setSelection(0);
                } else {
                    if (!file.canRead()) {
                        showErrorBox(getString(R.string.AccessError));
                        return;
                    }
                    if (sizeLimit != 0) {
                        if (file.length() > sizeLimit) {
                            showErrorBox(getString(R.string.FileUploadLimit, Utilities.formatFileSize(sizeLimit)));
                            return;
                        }
                    }
                    if (file.length() == 0) {
                        return;
                    }
                    if (delegate != null) {
                        delegate.didSelectFile(DocumentSelectActivity.this, file.getAbsolutePath());
                    }
                }
            }
        });

        listView.setOnTouchListener(new OnSwipeTouchListener() {
            public void onSwipeRight() {
                finishFragment(true);
            }
        });
        listRoots();
    } else {
        ViewGroup parent = (ViewGroup) fragmentView.getParent();
        if (parent != null) {
            parent.removeView(fragmentView);
        }
    }
    return fragmentView;
}
 
Example 20
Source File: UserDictionarySettings.java    From Android-Keyboard with Apache License 2.0 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Intent intent = getActivity().getIntent();
    final String localeFromIntent =
            null == intent ? null : intent.getStringExtra("locale");

    final Bundle arguments = getArguments();
    final String localeFromArguments =
            null == arguments ? null : arguments.getString("locale");

    final String locale;
    if (null != localeFromArguments) {
        locale = localeFromArguments;
    } else if (null != localeFromIntent) {
        locale = localeFromIntent;
    } else {
        locale = null;
    }

    mLocale = locale;
    // WARNING: The following cursor is never closed! TODO: don't put that in a member, and
    // make sure all cursors are correctly closed. Also, this comes from a call to
    // Activity#managedQuery, which has been deprecated for a long time (and which FORBIDS
    // closing the cursor, so take care when resolving this TODO). We should either use a
    // regular query and close the cursor, or switch to a LoaderManager and a CursorLoader.
    mCursor = createCursor(locale);
    TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
    emptyView.setText(R.string.user_dict_settings_empty_text);

    final ListView listView = getListView();
    listView.setAdapter(createAdapter());
    listView.setFastScrollEnabled(true);
    listView.setEmptyView(emptyView);

    setHasOptionsMenu(true);
    // Show the language as a subtitle of the action bar
    getActivity().getActionBar().setSubtitle(
            UserDictionarySettingsUtils.getLocaleDisplayName(getActivity(), mLocale));
}