Java Code Examples for android.widget.ListView#setStackFromBottom()

The following examples show how to use android.widget.ListView#setStackFromBottom() . These examples are extracted from open source projects. 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
/**
 * Setup list view to show logcat log-entries.
 * @param rootView root view.
 */
private void setupLogListView(final View rootView){
    //Log entry list view
    mListView = (ListView) rootView.findViewById(R.id.list);
    mListView.setStackFromBottom(true);
    mListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
    mAdapter = new LogcatViewerListAdapter(getApplicationContext());
    mListView.setAdapter(mAdapter);
}
 
Example 2
Source Project: bither-android   File: CheckFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    int resource = R.layout.fragment_check_cold;
    View view = inflater.inflate(resource, container, false);
    flContainer = (FrameLayout) view.findViewById(R.id.fl_container);
    vCheckHeader = (CheckHeaderView) view.findViewById(R.id.v_check_header);
    lv = (ListView) view.findViewById(R.id.lv);
    fl = (FrameLayout) view.findViewById(R.id.fl);
    lv.setStackFromBottom(false);
    lv.setAdapter(adapter);
    vCheckHeader.setListener(this);
    return view;
}
 
Example 3
Source Project: tickmate   File: Tickmate.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_tickmate_list);

       RelativeLayout progress = new RelativeLayout(this);
       progress.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, 100));
       progress.setGravity(Gravity.CENTER);
       progress.addView(new ProgressBar(this));

       mAdapter = new InfiniteScrollAdapter<>(this,
               new TickAdapter(this, null, savedInstanceState), progress);
       mAdapter.addListener(this);

       mHandler = new Handler();

       mListHeader = (TickHeader) findViewById(R.id.list_header);
       mListHeader.initialize(this);

       mListView = (ListView) findViewById(android.R.id.list);
       mListView.setStackFromBottom(true);
       mListView.setAdapter(mAdapter);
       mListView.setOnTouchListener(mListHeader);
       mListView.getEmptyView().setOnClickListener(this);
       mListView.getEmptyView().setOnTouchListener(mListHeader);
}
 
Example 4
Source Project: debugoverlay   File: DebugOverlayView.java    License: Apache License 2.0 4 votes vote down vote up
public DebugOverlayView(Context context) {
  super(context);

  windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  Point windowDimen = new Point();
  windowManager.getDefaultDisplay().getSize(windowDimen);

  int desiredLayoutHeight = dpToPx(context, 100);
  int layoutHeight = desiredLayoutHeight < windowDimen.y ? desiredLayoutHeight : windowDimen.y;

  // Setup the GUI

  // Close Button
  int buttonHeight = dpToPx(context, 40);
  closeButton = new ImageView(context);
  closeButton.setImageResource(R.drawable.ic_close_circle);
  closeButton.setLayoutParams(new FrameLayout.LayoutParams(buttonHeight, buttonHeight, Gravity.TOP | Gravity.END));

  // Logging Console
  adapter = new LoggingAdapter(context);
  listView = new ListView(context);
  listView.setBackgroundColor(Color.parseColor("#64000000"));
  listView.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
  listView.setStackFromBottom(true);
  listView.setAdapter(adapter);
  FrameLayout.LayoutParams listViewLayoutParams =
      new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
  listViewLayoutParams.topMargin = buttonHeight / 2;
  listView.setLayoutParams(listViewLayoutParams);

  // Add views
  addView(listView);
  addView(closeButton);

  // Set View parameters
  WindowManager.LayoutParams windowParams;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    windowParams = new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, layoutHeight,
        WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
  } else {
    windowParams =
        new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, layoutHeight, WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
  }

  windowParams.gravity = Gravity.TOP | Gravity.START;
  windowParams.x = 0;
  windowParams.y = windowDimen.y - layoutHeight;

  // Attach and display View
  windowManager.addView(this, windowParams);
}
 
Example 5
Source Project: 4pdaClient-plus   File: TabDrawerMenu.java    License: Apache License 2.0 4 votes vote down vote up
TabDrawerMenu(Activity activity, SelectItemListener listener) {
    Resources resources = App.getInstance().getResources();
    DisplayMetrics displayMetrics = resources.getDisplayMetrics();
    float dpWidth = displayMetrics.widthPixels;
    if (dpWidth > displayMetrics.density * 400) {
        dpWidth = displayMetrics.density * 400;
    }
    dpWidth -= 80 * displayMetrics.density;
    mActivity = activity;
    mSelectItemListener = listener;
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    Button closeAll = (Button) findViewById(R.id.closeAll);
    closeAll.setOnClickListener(v -> {
        if (App.getInstance().getTabItems().size() > 1)
            closeAllTabs();
        else {
            closeDialog();
            toggleOpenState();
        }
    });
    closeAll.setOnLongClickListener(v -> {
        toggleOpenState();
        closeDialog();
        return false;
    });


    mDrawer = (RelativeLayout) findViewById(R.id.tab_drawer);
    mListView = (ListView) findViewById(R.id.tab_list);
    mListView.setOnItemClickListener(new TabOnClickListener());
    mListView.setStackFromBottom(App.getInstance().getPreferences().getBoolean("tabsBottom", false));

    DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) mDrawer.getLayoutParams();
    params.width = (int) dpWidth;
    if ("right".equals(Preferences.System.getDrawerMenuPosition())) {
        params.gravity = Gravity.START;
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_start, GravityCompat.START);
    } else {
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_end, GravityCompat.END);
    }
    mDrawer.setLayoutParams(params);

    adapter = new TabAdapter(getContext(), R.layout.tab_drawer_item, App.getInstance().getTabItems());
    mListView.setAdapter(adapter);
}
 
Example 6
@Override
protected void onCreate(Bundle savedInstanceState) {
       if (hasSmartBar()) {
           getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
       }

	super.onCreate(savedInstanceState);
	setContentView(R.layout.direct_message_conversation);
	
	// Argument
	mUser = getIntent().getParcelableExtra("user");
	getActionBar().setTitle(mUser.getName());
	
	// View
	mSwipeRefresh = (SwipeUpAndDownRefreshLayout) findViewById(R.id.direct_message_refresh);
	mSwipeRefresh.setOnRefreshListener(this);
	mSwipeRefresh.setDownHasPriority();
	mSwipeRefresh.setColorScheme(R.color.ptr_green, R.color.ptr_orange, R.color.ptr_red, R.color.ptr_blue);
	
	mList = (ListView) findViewById(R.id.direct_message_conversation);
	mText = (EditText) findViewById(R.id.direct_message_send_text);
	mSend = (ImageView) findViewById(R.id.direct_message_send);
	
	mList.setStackFromBottom(true);
	mAdapter = new DirectMessageAdapter(this, mMsgList, mUser.id);
	mList.setAdapter(mAdapter);
	
	mSend.setOnClickListener(this);
	
	// Emoticon Picker
	mEmoticons = new EmoticonFragment();
	mEmoticons.setEmoticonListener(new EmoticonFragment.EmoticonListener() {
		@Override
		public void onEmoticonSelected(String name) {
			if (!mRefreshing) {
				mText.getText().append(name);
			}
		}
	});
	getFragmentManager().beginTransaction().replace(R.id.direct_message_emoticons, mEmoticons).commit();
	
	new Refresher().execute(true);
}
 
Example 7
Source Project: tapchat-android   File: BufferFragment.java    License: Apache License 2.0 4 votes vote down vote up
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
       LinearLayout layout = new LinearLayout(getActivity());
       layout.setOrientation(LinearLayout.VERTICAL);
       layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));

        View connectionHeaderView = inflater.inflate(R.layout.connection_header, null);
        layout.addView(connectionHeaderView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

        View bufferHeaderView = inflater.inflate(R.layout.fragment_buffer_header, null);
        layout.addView(bufferHeaderView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

        ListView listView = new ListView(getActivity());
        listView.setId(android.R.id.list);
        listView.setDivider(null);
        listView.setStackFromBottom(true);
        listView.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_NORMAL);
        listView.setSmoothScrollbarEnabled(false);
//        listView.setCacheColorHint(Color.TRANSPARENT);

        LayoutParams params = new LayoutParams(MATCH_PARENT, 0);
        params.weight = 1;
        layout.addView(listView, params);
        View footerView = inflater.inflate(R.layout.fragment_buffer_footer, null);
        layout.addView(footerView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

        ((TextView) footerView.findViewById(R.id.text_entry)).setOnEditorActionListener(new TextView.OnEditorActionListener() {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (event != null && event.getAction() != KeyEvent.ACTION_DOWN) {
                    return false;
                }

                sendMessage();
                return true;
            }
        });

        footerView.findViewById(R.id.send_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sendMessage();
            }
        });

        return layout;
    }