Java Code Examples for android.widget.ListView.post()

The following are Jave code examples for showing how to use post() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Musicoco   File: OptionsDialog.java   View Source Code Vote up 6 votes
public OptionsDialog(Activity activity) {
    this.activity = activity;
    this.mDialog = new Dialog(activity, R.style.BottomDialog);

    mDialog.getWindow().setGravity(Gravity.BOTTOM);
    mDialog.getWindow().setWindowAnimations(R.style.BottomDialog_Animation);
    mDialog.setCanceledOnTouchOutside(true);

    View view = LayoutInflater.from(activity).inflate(R.layout.options_container, null);
    listView = (ListView) view.findViewById(R.id.options_list);

    contentView = (LinearLayout) view.findViewById(R.id.options_container);

    titleText = (TextView) view.findViewById(R.id.options_title);
    divide = view.findViewById(R.id.options_divide);
    mDialog.setContentView(view);
    listView.post(new Runnable() {
        @Override
        public void run() {
            setDialogHeight();
        }
    });
}
 
Example 2
Project: MyPlace   File: MessageActivity.java   View Source Code Vote up 5 votes
private void scrollMyListView(final int position) {
    final ListView myListView = (ListView) findViewById(R.id.listMessages);
    myListView.post(new Runnable() {
        @Override
        public void run() {
            // Select the last row so it will scroll into view...
            myListView.setSelection(position);
        }
    });
}
 
Example 3
Project: planetcon   File: ListPlayersPreference.java   View Source Code Vote up 5 votes
@Override
protected View onCreateDialogView() {
    int numPlayers = mPrefs.getInt(SettingsActivity.KEY_PLAYERS_LIST, SettingsActivity.DEF_PLAYERS_LIST);
    ListView listPlayers = new ListView(mContext);
    listPlayers.setAdapter(mListAdapter);
    mListAdapter.setCount(numPlayers);

    // Needed to show the keyboard when a editText inside the listView is focused
    listPlayers.post(new Runnable() {
        @Override
        public void run() {
            Window window = getDialog().getWindow();
            if (window != null) {
                window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
            }
        }
    });

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    LinearLayout linearLayout = new LinearLayout(mContext);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    // Needed to avoid autofocus of editText views
    linearLayout.setFocusableInTouchMode(true);
    linearLayout.addView(listPlayers, layoutParams);

    return linearLayout;
}
 
Example 4
Project: microMathematics   File: FileListView.java   View Source Code Vote up 5 votes
public final void setSelection(int i, int y_)
{
    final ListView flv$ = listView;
    final int position$ = i, y$ = y_;
    flv$.post(new Runnable()
    {
        public void run()
        {
            flv$.setSelectionFromTop(position$, y$ > 0 ? y$ : flv$.getHeight() / 2);
        }
    });
    currentPosition = i;
}
 
Example 5
Project: decoy   File: ListViewUtil.java   View Source Code Vote up 5 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static void scrollToPosition(final ListView messageListView, final int position, final int y, final ScrollToPositionListener listener) {
	messageListView.post(new Runnable() {
		
		@Override
		public void run() {				
			messageListView.setSelectionFromTop(position, y);
			
			if (listener != null) {
				listener.onScrollEnd();
			}
		}
	});			
}
 
Example 6
Project: BlackList   File: InformationFragment.java   View Source Code Vote up 4 votes
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    listView = (ListView) view.findViewById(R.id.help_list);

    InformationArrayAdapter adapter = new InformationArrayAdapter(getContext());

    adapter.addTitle(R.string.About);
    String title = getString(R.string.app_name) + " (" + getAppVersion() + ")";
    adapter.addText(title, getString(R.string.Info_about));

    adapter.addTitle(R.string.Attention);
    adapter.addText(R.string.Info_attention);

    adapter.addTitle(R.string.Messaging);
    adapter.addText(R.string.Info_messaging);

    adapter.addTitle(R.string.Black_list);
    adapter.addText(R.string.Info_black_list);

    adapter.addTitle(R.string.White_list);
    adapter.addText(R.string.Info_white_list);

    adapter.addTitle(R.string.Journal);
    adapter.addText(R.string.Info_journal);

    adapter.addTitle(R.string.Settings);
    adapter.addText(R.string.Info_settings);

    adapter.addTitle(R.string.Licence);
    adapter.addText(R.string.Info_licence);

    adapter.addTitle(R.string.Author);
    adapter.addText(R.string.Info_author);

    // add adapter to the ListView and scroll list to position
    listView.setAdapter(adapter);
    listView.post(new Runnable() {
        @Override
        public void run() {
            listView.setSelection(listPosition);
        }
    });
}