本文整理匯總了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);
}
});
}