Search in sources :

Example 16 with ListView

use of android.widget.ListView in project boilerplate by koush.

the class SimpleListFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    ListView lv = (ListView) parent;
    if (position < lv.getHeaderViewsCount())
        return;
    adapter.getItem(position - lv.getHeaderViewsCount()).onClick();
}
Also used : ListView(android.widget.ListView)

Example 17 with ListView

use of android.widget.ListView in project ion by koush.

the class TwitterGson method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Enable global Ion logging
    Ion.getDefault(this).configure().setLogging("ion-sample", Log.DEBUG);
    // create a tweet adapter for our list view
    tweetAdapter = new ArrayAdapter<Tweet>(this, 0) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null)
                convertView = getLayoutInflater().inflate(R.layout.tweet, null);
            // we're near the end of the list adapter, so load more items
            if (position >= getCount() - 3)
                load();
            // grab the tweet (or retweet)
            Tweet tweet = getItem(position);
            Tweet retweet = tweet.retweetedStatus;
            if (retweet != null)
                tweet = retweet;
            ImageView imageView = (ImageView) convertView.findViewById(R.id.image);
            // Use Ion's builder set the google_image on an ImageView from a URL
            // start with the ImageView
            Ion.with(imageView).placeholder(R.drawable.twitter).load(tweet.user.imageUrl);
            // and finally, set the name and text
            TextView handle = (TextView) convertView.findViewById(R.id.handle);
            handle.setText(tweet.user.screenName);
            TextView text = (TextView) convertView.findViewById(R.id.tweet);
            text.setText(tweet.text);
            return convertView;
        }
    };
    // basic setup of the ListView and adapter
    setContentView(R.layout.twitter);
    ListView listView = (ListView) findViewById(R.id.list);
    listView.setAdapter(tweetAdapter);
    // authenticate and do the first load
    getCredentials();
}
Also used : ListView(android.widget.ListView) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

Example 18 with ListView

use of android.widget.ListView in project glitch-hq-android by tinyspeck.

the class ListViewUtil method getListViewHeightBasedOnChildren.

public static int getListViewHeightBasedOnChildren(ListView listView) {
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter == null) {
        return -1;
    }
    int totalHeight = 0;
    for (int i = 0; i < listAdapter.getCount(); i++) {
        View listItem = listAdapter.getView(i, null, listView);
        listItem.measure(0, 0);
        Log.i("measure", " i: " + i + " size: " + listItem.getMeasuredHeight());
        totalHeight += listItem.getMeasuredHeight();
    }
    return totalHeight;
}
Also used : View(android.view.View) ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter)

Example 19 with ListView

use of android.widget.ListView in project Float-Bar by tianzhijiexian.

the class DrawService method updateUi.

/**
	 * 更新悬浮窗布局等
	 */
private void updateUi() {
    RIGHT_MODE = !prefs.getDrawMode();
    DRAW_COLOR = prefs.getDrawColor();
    ALPHA = prefs.getDrawAlpha();
    // 获取浮动窗口视图所在布局
    layout = (LinearLayout) inflater.inflate(RIGHT_MODE ? R.layout.draw_right : R.layout.draw_left, null);
    // 添加悬浮窗的视图
    mWindowManager.addView(layout, wmParams);
    /**
		 * 设置抽屉控件的打开方向和监听器
		 */
    mDrawerLayout = (DrawerLayout) layout.findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerListener(new MyDrawListener());
    mDrawerLayout.openDrawer(RIGHT_MODE ? Gravity.RIGHT : Gravity.LEFT);
    /**
		 * 设置上方的home键
		 */
    Button home = (Button) layout.findViewById(R.id.home_key);
    home.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Util.virtualHome(getBaseContext());
            stopSelf();
        }
    });
    /**
		 * 设置抽屉控件内的背景
		 */
    drawContent = (LinearLayout) layout.findViewById(R.id.drawer_content);
    drawContent.setBackgroundColor(DRAW_COLOR);
    drawContent.getBackground().setAlpha(ALPHA);
    /**
		 * 设置最近任务list中item的个数:20
		 */
    Util.reloadButtons(this, appInfos, 20);
    ListView listView = (ListView) layout.findViewById(R.id.drawer_list);
    listView.setAdapter(new AppAdapter(this, mWindowManager, layout, mDrawerLayout, appInfos));
    // 悬浮窗显示确定右上角为起始坐标
    wmParams.gravity = RIGHT_MODE ? Gravity.RIGHT : Gravity.LEFT | Gravity.TOP;
    // 以屏幕右上角为原点,设置x、y初始值,确定显示窗口的起始位置
    // 添加动画。参考自:http://bbs.9ria.com/thread-242912-1-1.html
    wmParams.windowAnimations = (RIGHT_MODE) ? R.style.right_anim : R.style.left_anim;
    mWindowManager.updateViewLayout(layout, wmParams);
}
Also used : AppAdapter(com.kale.floatbar.adapter.AppAdapter) ListView(android.widget.ListView) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) View(android.view.View) ListView(android.widget.ListView)

Example 20 with ListView

use of android.widget.ListView in project PreLollipopTransition by takahirom.

the class ListViewActivityTest method testListClick.

public void testListClick() throws InterruptedException {
    Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity.class.getName(), null, false);
    Spoon.screenshot(getActivity(), "init");
    // listviewactivity -> subactivity
    final ListView listView = (ListView) getActivity().findViewById(R.id.list);
    instrumentation.waitForIdleSync();
    instrumentation.runOnMainSync(new Runnable() {

        @Override
        public void run() {
            assertTrue(listView.performItemClick(listView.getChildAt(0), 0, 0));
        }
    });
    Activity detailActivity = instrumentation.waitForMonitor(monitor);
    // Wait for animation
    Thread.sleep(2000l);
    instrumentation.waitForIdleSync();
    Spoon.screenshot(detailActivity, "listview_transition");
    // subactivity -> listviewactivity
    sendKeys(KeyEvent.KEYCODE_BACK);
    // Wait for animation
    Thread.sleep(2000l);
    instrumentation.waitForIdleSync();
    Spoon.screenshot(getActivity(), "listview_transition_backpress");
}
Also used : ListView(android.widget.ListView) Instrumentation(android.app.Instrumentation) Activity(android.app.Activity)

Aggregations

ListView (android.widget.ListView)1139 View (android.view.View)739 AdapterView (android.widget.AdapterView)444 TextView (android.widget.TextView)389 ImageView (android.widget.ImageView)167 Intent (android.content.Intent)148 AbsListView (android.widget.AbsListView)135 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)97 ArrayAdapter (android.widget.ArrayAdapter)97 ArrayList (java.util.ArrayList)81 ViewGroup (android.view.ViewGroup)75 ListAdapter (android.widget.ListAdapter)71 OnClickListener (android.view.View.OnClickListener)65 LayoutInflater (android.view.LayoutInflater)63 Bundle (android.os.Bundle)57 Button (android.widget.Button)55 LinearLayout (android.widget.LinearLayout)50 SuppressLint (android.annotation.SuppressLint)34 DialogInterface (android.content.DialogInterface)34 ScrollView (android.widget.ScrollView)31