本文整理汇总了Java中android.widget.ListView.post方法的典型用法代码示例。如果您正苦于以下问题:Java ListView.post方法的具体用法?Java ListView.post怎么用?Java ListView.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ListView
的用法示例。
在下文中一共展示了ListView.post方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OptionsDialog
import android.widget.ListView; //导入方法依赖的package包/类
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();
}
});
}
示例2: scrollMyListView
import android.widget.ListView; //导入方法依赖的package包/类
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);
}
});
}
示例3: onCreateDialogView
import android.widget.ListView; //导入方法依赖的package包/类
@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;
}
示例4: setSelection
import android.widget.ListView; //导入方法依赖的package包/类
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;
}
示例5: scrollToPosition
import android.widget.ListView; //导入方法依赖的package包/类
@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();
}
}
});
}
示例6: onViewCreated
import android.widget.ListView; //导入方法依赖的package包/类
@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);
}
});
}