Search in sources :

Example 46 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project K6nele by Kaljurand.

the class AppListActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    mCurrentSortOrder = prefs.getString(getString(R.string.prefCurrentSortOrder), App.Columns.COUNT + " DESC");
    ListView lv = getListView();
    setEmptyView(getString(R.string.emptylistApps));
    AppListCursorAdapter mAdapter = getAdapter(mCurrentSortOrder);
    lv.setAdapter(mAdapter);
    registerForContextMenu(lv);
    lv.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor cursor = (Cursor) parent.getItemAtPosition(position);
            String fname = cursor.getString(cursor.getColumnIndex(App.Columns.FNAME));
            Intent intent = IntentUtils.getAppIntent(getApplicationContext(), fname);
            if (intent != null) {
                startActivity(intent);
            } else {
                toast(String.format(getString(R.string.errorFailedLaunchApp), fname));
            }
        }
    });
}
Also used : ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) Cursor(android.database.Cursor) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 47 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project XCL-Charts by xcltapestry.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView mListView = new ListView(this);
    SimpleAdapter adapter = new SimpleAdapter(this, getData(), android.R.layout.simple_list_item_2, new String[] { "title", "description" }, new int[] { android.R.id.text1, android.R.id.text2 });
    mListView.setAdapter(adapter);
    final LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(mListView);
    setContentView(layout);
    setTitle("XCL-Charts demo");
    OnItemClickListener listener = new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, android.view.View view, int position, long id) {
            // TODO Auto-generated method stub
            String[] chartsTitleCurr = getResources().getStringArray(R.array.chartsTitle);
            if (position > chartsTitleCurr.length - 1)
                return;
            Bundle bundleSimple = new Bundle();
            Intent intent = new Intent();
            bundleSimple.putString("title", chartsTitleCurr[position]);
            int id_desc_3_4 = chartsTitleCurr.length - 4;
            if (// 倒数1 仪表盘
            position == chartsTitleCurr.length - 1) {
                intent.setClass(MainActivity.this, GaugeChartActivity.class);
            } else if (// 倒数2  圆/半圆图
            position == chartsTitleCurr.length - 2) {
                intent.setClass(MainActivity.this, CircleChartActivity.class);
            // }else if(position >= id_desc_1_2_3) //倒数1,2,3 seekbar图
            // {
            // position = chartsTitleCurr.length - 1 - position;
            // intent.setClass(MainActivity.this,SeekBarActivity.class);
            } else if (// 倒数3,4 同源汇总图
            position >= id_desc_3_4) {
                position = chartsTitleCurr.length - 3 - position;
                intent.setClass(MainActivity.this, SpinnerActivity.class);
            } else if (// 倒数5  scroll view line
            position >= chartsTitleCurr.length - 5) {
                intent.setClass(MainActivity.this, HLNScrollActivity.class);
            } else if (// 倒数6  scroll view bar
            position >= chartsTitleCurr.length - 6) {
                intent.setClass(MainActivity.this, HBARScrollActivity.class);
            } else if (// 倒数6  scroll view bar
            position >= chartsTitleCurr.length - 7) {
                position = chartsTitleCurr.length - 7 - position;
                intent.setClass(MainActivity.this, ClickChartsActivity.class);
            } else if (// 倒数8  dial chart
            position >= chartsTitleCurr.length - 8) {
                position = chartsTitleCurr.length - 8 - position;
                intent.setClass(MainActivity.this, DialChartActivity.class);
            } else if (// 倒数9  dial chart
            position >= chartsTitleCurr.length - 9) {
                position = chartsTitleCurr.length - 9 - position;
                intent.setClass(MainActivity.this, DialChart2Activity.class);
            } else if (// 倒数9  dial chart
            position >= chartsTitleCurr.length - 10) {
                position = chartsTitleCurr.length - 10 - position;
                intent.setClass(MainActivity.this, DialChart3Activity.class);
            } else if (// 倒数9  dial chart
            position >= chartsTitleCurr.length - 11) {
                position = chartsTitleCurr.length - 11 - position;
                intent.setClass(MainActivity.this, DialChart4Activity.class);
            } else if (// 倒数9  dial chart
            position >= chartsTitleCurr.length - 12) {
                position = chartsTitleCurr.length - 12 - position;
                intent.setClass(MainActivity.this, DySpActivity.class);
            } else {
                intent.setClass(MainActivity.this, ChartsActivity.class);
            }
            /*
				 if(position >= chartsTitleCurr.length - 3) //倒数1,2,3 seekbar图
				 {
					 position = chartsTitleCurr.length - 1 - position;
					 intent.setClass(MainActivity.this,SeekBarActivity.class);						
				 }else if(position >= chartsTitleCurr.length - 5) ////倒数4,5 同源汇总图
				 {
					 position = chartsTitleCurr.length - 4 - position;
					 intent.setClass(MainActivity.this,SpinnerActivity.class);						
				 }else{				
					 intent.setClass(MainActivity.this,ChartsActivity.class);					
				 }	
				 */
            bundleSimple.putInt("selected", position);
            intent.putExtras(bundleSimple);
            startActivity(intent);
        }
    };
    mListView.setOnItemClickListener(listener);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) SimpleAdapter(android.widget.SimpleAdapter) Intent(android.content.Intent) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) LinearLayout(android.widget.LinearLayout)

Example 48 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project SharedPreferenceInspector by PrashamTrivedi.

the class SharedPreferencesList method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ListView lists = getListView();
    /**
     * Get access to shared preferences list.
     */
    File sharedPrefsDir = new File(getActivity().getApplicationInfo().dataDir, "shared_prefs");
    if (sharedPrefsDir.exists() && sharedPrefsDir.isDirectory()) {
        /**
         * If exists and is directory, get the list.
         */
        final String[] list = sharedPrefsDir.list();
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, list);
        lists.setAdapter(adapter);
        setListAdapter(adapter);
        lists.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String name = list[position];
                Bundle bundle = new Bundle();
                /**
                 * Remove .xml from the file name.
                 */
                String prefName = name.substring(0, name.length() - 4);
                bundle.putString("name", prefName);
                SharedPreferencesItem sharedPreferencesItem = SharedPreferencesItem.newInstance(bundle);
                ((SharedPrefsBrowser) getActivity()).startFragment(sharedPreferencesItem, "PreferencesList", true);
            }
        });
    } else {
        setListAdapter(null);
        setEmptyText("Nothing shared in stored preference");
    }
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) File(java.io.File) ArrayAdapter(android.widget.ArrayAdapter)

Example 49 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project SmartCampus by Vegen.

the class EaseEmojiconPagerView method getGroupGridViews.

/**
 * get emojicon group gridview list
 * @param groupEntity
 * @return
 */
public List<View> getGroupGridViews(EaseEmojiconGroupEntity groupEntity) {
    List<EaseEmojicon> emojiconList = groupEntity.getEmojiconList();
    int itemSize = emojiconColumns * emojiconRows - 1;
    int totalSize = emojiconList.size();
    Type emojiType = groupEntity.getType();
    if (emojiType == Type.BIG_EXPRESSION) {
        itemSize = bigEmojiconColumns * bigEmojiconRows;
    }
    int pageSize = totalSize % itemSize == 0 ? totalSize / itemSize : totalSize / itemSize + 1;
    List<View> views = new ArrayList<View>();
    for (int i = 0; i < pageSize; i++) {
        View view = View.inflate(context, R.layout.ease_expression_gridview, null);
        GridView gv = (GridView) view.findViewById(R.id.gridview);
        if (emojiType == Type.BIG_EXPRESSION) {
            gv.setNumColumns(bigEmojiconColumns);
        } else {
            gv.setNumColumns(emojiconColumns);
        }
        List<EaseEmojicon> list = new ArrayList<EaseEmojicon>();
        if (i != pageSize - 1) {
            list.addAll(emojiconList.subList(i * itemSize, (i + 1) * itemSize));
        } else {
            list.addAll(emojiconList.subList(i * itemSize, totalSize));
        }
        if (emojiType != Type.BIG_EXPRESSION) {
            EaseEmojicon deleteIcon = new EaseEmojicon();
            deleteIcon.setEmojiText(EaseSmileUtils.DELETE_KEY);
            list.add(deleteIcon);
        }
        final EmojiconGridAdapter gridAdapter = new EmojiconGridAdapter(context, 1, list, emojiType);
        gv.setAdapter(gridAdapter);
        gv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                EaseEmojicon emojicon = gridAdapter.getItem(position);
                if (pagerViewListener != null) {
                    String emojiText = emojicon.getEmojiText();
                    if (emojiText != null && emojiText.equals(EaseSmileUtils.DELETE_KEY)) {
                        pagerViewListener.onDeleteImageClicked();
                    } else {
                        pagerViewListener.onExpressionClicked(emojicon);
                    }
                }
            }
        });
        views.add(view);
    }
    return views;
}
Also used : EmojiconGridAdapter(com.hyphenate.easeui.adapter.EmojiconGridAdapter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) Type(com.hyphenate.easeui.domain.EaseEmojicon.Type) EaseEmojicon(com.hyphenate.easeui.domain.EaseEmojicon) GridView(android.widget.GridView)

Example 50 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project SmartCampus by Vegen.

the class EaseContactListFragment method setUpView.

@Override
protected void setUpView() {
    EMClient.getInstance().addConnectionListener(connectionListener);
    contactList = new ArrayList<EaseUser>();
    getContactList();
    // init list
    contactListLayout.init(contactList);
    if (listItemClickListener != null) {
        listView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                EaseUser user = (EaseUser) listView.getItemAtPosition(position);
                listItemClickListener.onListItemClicked(user);
            }
        });
    }
    query.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            contactListLayout.filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideSoftKeyboard();
            return false;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) MotionEvent(android.view.MotionEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) OnClickListener(android.view.View.OnClickListener) EaseUser(com.hyphenate.easeui.domain.EaseUser)

Aggregations

OnItemClickListener (android.widget.AdapterView.OnItemClickListener)241 AdapterView (android.widget.AdapterView)238 View (android.view.View)237 ListView (android.widget.ListView)188 TextView (android.widget.TextView)135 ImageView (android.widget.ImageView)86 Intent (android.content.Intent)68 OnClickListener (android.view.View.OnClickListener)44 SuppressLint (android.annotation.SuppressLint)32 LayoutInflater (android.view.LayoutInflater)32 AlertDialog (android.app.AlertDialog)27 DialogInterface (android.content.DialogInterface)27 GridView (android.widget.GridView)26 ArrayAdapter (android.widget.ArrayAdapter)24 Bundle (android.os.Bundle)23 Dialog (android.app.Dialog)22 ArrayList (java.util.ArrayList)21 Paint (android.graphics.Paint)17 File (java.io.File)17 AbsListView (android.widget.AbsListView)16