Search in sources :

Example 41 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project LitePal by LitePalFramework.

the class TableListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.table_list_layout);
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mTableListview = (ListView) findViewById(R.id.table_listview);
    mAdapter = new StringArrayAdapter(this, 0, mList);
    mTableListview.setAdapter(mAdapter);
    populateTables();
    mTableListview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int index, long id) {
            TableStructureActivity.actionStart(TableListActivity.this, mList.get(index));
        }
    });
}
Also used : StringArrayAdapter(org.litepal.litepalsample.adapter.StringArrayAdapter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 42 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project MFCalendarView by MustafaFerhan.

the class MFCalendarView method init.

void init(Context context) {
    LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = li.inflate(R.layout.mf_calendarview, null, false);
    month = (GregorianCalendar) GregorianCalendar.getInstance();
    month.setTimeInMillis(Util.dateToLong(getInitialDate()));
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Util.getLocale());
    currentSelectedDate = df.format(month.getTime());
    calendaradapter = new CalendarAdapter(context, month);
    gridview = (ExpandableHeightGridView) view.findViewById(R.id.gridview);
    gridview.setAdapter(calendaradapter);
    handler = new Handler();
    handler.post(calendarUpdater);
    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(android.text.format.DateFormat.format("MMMM yyyy", month));
    RelativeLayout previous = (RelativeLayout) view.findViewById(R.id.previous);
    previous.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setPreviousMonth();
            refreshCalendar();
        }
    });
    RelativeLayout next = (RelativeLayout) view.findViewById(R.id.next);
    next.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setNextMonth();
            refreshCalendar();
        }
    });
    gridview.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            ((CalendarAdapter) parent.getAdapter()).setSelected(v);
            currentSelectedDate = CalendarAdapter.dayString.get(position);
            String[] separatedTime = currentSelectedDate.split("-");
            String gridvalueString = separatedTime[2].replaceFirst("^0*", // taking last part of date. ie; 2 from 2012-12-02.
            "");
            int gridvalue = Integer.parseInt(gridvalueString);
            // navigate to next or previous month on clicking offdays.
            if ((gridvalue > 10) && (position < 8)) {
                setPreviousMonth();
                refreshCalendar();
            } else if ((gridvalue < 15) && (position > 28)) {
                setNextMonth();
                refreshCalendar();
            }
            ((CalendarAdapter) parent.getAdapter()).setSelected(v);
            month.setTimeInMillis(Util.dateToLong(currentSelectedDate));
            calendaradapter.initCalendarAdapter(month, calendarListener);
            if (calendarListener != null)
                calendarListener.onDateChanged(currentSelectedDate);
        }
    });
    addView(view);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Handler(android.os.Handler) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) LayoutInflater(android.view.LayoutInflater) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) SimpleDateFormat(java.text.SimpleDateFormat)

Example 43 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class PlaceActivity3 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_1);
    textStatus = (TextView) findViewById(R.id.textStatus);
    listView = (ListView) findViewById(R.id.listView);
    gp = new GooglePlaceSearch(ApiKey);
    gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {

        public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
            textStatus.setText("Status : " + status);
            if (status.equals(GooglePlaceSearch.STATUS_OK)) {
                ArrayList<String> array = new ArrayList<String>();
                final ArrayList<String> array_photo = new ArrayList<String>();
                for (int i = 0; i < arr_data.size(); i++) {
                    array.add("Name : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME) + "\n" + "Address : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_ADDRESS) + "\n" + "Latitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LATITUDE) + "\n" + "Longitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LONGITUDE) + "\n" + "Phone Number : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHONENUMBER));
                    array_photo.add(arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHOTO));
                }
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(PlaceActivity3.this, R.layout.listview_text, array);
                listView.setAdapter(adapter);
                listView.setOnItemClickListener(new OnItemClickListener() {

                    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                        Dialog dialog = new Dialog(PlaceActivity3.this);
                        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        dialog.setContentView(R.layout.dialog_photo);
                        dialog.setCancelable(true);
                        final ImageView imgPhoto = (ImageView) dialog.findViewById(R.id.imgPhoto);
                        dialog.show();
                        gp.getPhotoBitmapByWidth(array_photo.get(arg2), 600, "", new OnBitmapResponseListener() {

                            public void onResponse(Bitmap bm, String tag) {
                                imgPhoto.setImageBitmap(bm);
                            }
                        });
                    }
                });
            }
        }
    });
    gp.getNearby(latitude, longitude, radius, type, language, keyword);
}
Also used : ContentValues(android.content.ContentValues) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) OnPlaceResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener) Document(org.w3c.dom.Document) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Bitmap(android.graphics.Bitmap) GooglePlaceSearch(app.akexorcist.gdaplibrary.GooglePlaceSearch) Dialog(android.app.Dialog) AdapterView(android.widget.AdapterView) OnBitmapResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnBitmapResponseListener) ImageView(android.widget.ImageView) ArrayAdapter(android.widget.ArrayAdapter)

Example 44 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project MWM-for-Android-Gen1 by MetaWatchOpenProjects.

the class DeviceSelection method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    pdWait = ProgressDialog.show(this, "Please wait", "Searching Bluetooth devices...");
    pdWait.setCancelable(true);
    pdWait.setOnCancelListener(new OnCancelListener() {

        public void onCancel(DialogInterface dialog) {
            Log.d(MetaWatch.TAG, "canceled");
            if (MetaWatchService.bluetoothAdapter.isDiscovering())
                MetaWatchService.bluetoothAdapter.cancelDiscovery();
            finish();
        }
    });
    pdWait.show();
    setContentView(R.layout.device_selection);
    //constructMenuList();
    listView = (ListView) findViewById(android.R.id.list);
    //listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menuList));
    listView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            Log.d(MetaWatch.TAG, "device selected: " + arg2);
            Map<String, String> map = list.get(arg2);
            String mac = map.get("mac");
            Log.d(MetaWatch.TAG, "mac selected: " + mac);
            MetaWatchService.Preferences.watchMacAddress = mac;
            MetaWatchService.saveMac(context, mac);
            sendToast("Selected watch set");
            finish();
        }
    });
    if (MetaWatchService.bluetoothAdapter == null)
        MetaWatchService.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    Set<BluetoothDevice> pairedDevices = MetaWatchService.bluetoothAdapter.getBondedDevices();
    if (pairedDevices.size() > 0) {
        for (BluetoothDevice device : pairedDevices) {
            addToList(device.getAddress(), device.getName());
        }
    }
    Receiver receiver = new Receiver();
    IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
    registerReceiver(receiver, intentFilter);
    MetaWatchService.bluetoothAdapter.startDiscovery();
}
Also used : IntentFilter(android.content.IntentFilter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) BluetoothDevice(android.bluetooth.BluetoothDevice) DialogInterface(android.content.DialogInterface) BroadcastReceiver(android.content.BroadcastReceiver) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) HashMap(java.util.HashMap) Map(java.util.Map) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 45 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project GT by Tencent.

the class GTLogSearchActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gt_log_search_activity);
    handler = new Handler();
    tv_count = (TextView) findViewById(R.id.log_search_count);
    btn_pre = (ImageButton) findViewById(R.id.log_msg_pre);
    btn_next = (ImageButton) findViewById(R.id.log_msg_next);
    /*
		 * 用于覆盖整个屏幕的透明ImageView,
		 * 主要帮助点击非filterListView区域使filterListView消失
		 */
    img_empty = (ImageView) findViewById(R.id.log_search_view_empty);
    img_empty.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch(event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    img_empty.setVisibility(View.GONE);
                    filterListView.setVisibility(View.GONE);
                    cancelFilterMsgInput(v);
                    break;
                case MotionEvent.ACTION_UP:
                    v.performClick();
                    break;
                default:
                    break;
            }
            return false;
        }
    });
    // 过滤数据展示列表
    filterListView = (ListView) findViewById(R.id.log_search_spinner_list);
    //		filterLock = new ReentrantLock();
    filterListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long arg3) {
            img_empty.setVisibility(View.GONE);
            filterListView.setVisibility(View.GONE);
            String sCurSelectedMsg = (String) parent.getAdapter().getItem(position);
            LinkedList<String> curShowDownMsgList = GTLogInternal.getCurShowDownMsgList();
            LinkedList<String> msgHistory = GTLogInternal.getCurSearchMsgHistory();
            GTLogInternal.setCurSearchMsg(sCurSelectedMsg);
            msgWatched = false;
            et_Msg.removeTextChangedListener(msg_watcher);
            String s = curShowDownMsgList.remove(position);
            curShowDownMsgList.addFirst(s);
            msgHistory.remove(s);
            msgHistory.addFirst(s);
            et_Msg.setText(sCurSelectedMsg);
            btn_msg_clear.setVisibility(View.VISIBLE);
            cancelFilterMsgInput(parent);
            //				filterLock.lock();
            ((MsgAdaptor) filterListView.getAdapter()).getFilter().filter(sCurSelectedMsg);
            //				filterLock.unlock();
            doSearch(sCurSelectedMsg);
        }
    });
    // 过滤文本
    et_Msg = (EditText) findViewById(R.id.log_search_msg);
    //		et_Msg.setText(BHLog.getCurSearchMsg());
    et_Msg.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!msgWatched) {
                et_Msg.addTextChangedListener(msg_watcher);
                msgWatched = true;
            }
            MsgAdaptor adapter = new MsgAdaptor(GTLogSearchActivity.this);
            adapter.getFilter().filter(et_Msg.getText().toString());
            //				filterLock.lock();
            filterListView.setAdapter(adapter);
            //				filterLock.unlock();
            if (!filterListView.getAdapter().isEmpty()) {
                filterListView.setVisibility(View.VISIBLE);
                img_empty.setVisibility(View.VISIBLE);
            }
        }
    });
    et_Msg.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            switch(keyCode) {
                case KeyEvent.KEYCODE_ENTER:
                    // 要先把过滤showdown去掉,否则会多弹出一次
                    msgWatched = false;
                    et_Msg.removeTextChangedListener(msg_watcher);
                    String word = et_Msg.getText().toString();
                    filterListView.setVisibility(View.GONE);
                    img_empty.setVisibility(View.GONE);
                    cancelFilterMsgInput(v);
                    if (word.trim().length() == 0) {
                        return true;
                    }
                    LinkedList<String> curShowDownMsgList = GTLogInternal.getCurShowDownMsgList();
                    LinkedList<String> msgHistory = GTLogInternal.getCurSearchMsgHistory();
                    msgHistory.remove(word);
                    msgHistory.addFirst(word);
                    curShowDownMsgList.remove(word);
                    curShowDownMsgList.addFirst(word);
                    doSearch(word);
                    return true;
            }
            return false;
        }
    });
    // 过滤文本的清理
    btn_msg_clear = (ImageButton) findViewById(R.id.log_msg_search_clear);
    btn_msg_clear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            et_Msg.setText("");
            // 清理本次搜索标记
            GTLogInternal.clearLastSearchMarks();
            tv_count.setText("0 / 0");
            arrayAdapter.notifyDataSetChanged();
            btn_msg_clear.setVisibility(View.GONE);
        }
    });
    // 改成back功能了
    btn_back = (Button) findViewById(R.id.log_msg_search_cancel);
    btn_back.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // 20130404 改成back功能了
            finish();
        }
    });
    btn_pre.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            int historySeq = GTLogInternal.getLastMatchedSeq();
            if (historySeq > 0) {
                GTLogInternal.setLastMatchedSeq(historySeq - 1);
                listView.setSelection(GTLogInternal.getLastMatchedEntryList().get(historySeq - 1).posionInDataSet);
                tv_count.setText(// 这里注意显示序号要比存储位置多1,因为从1开始算
                historySeq + " / " + GTLogInternal.getLastMatchedEntryList().size());
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        // 这个刷新需要在UI线程排队,否则会被listView.setSelection方法冲突掉
                        arrayAdapter.notifyDataSetChanged();
                    }
                });
            } else if (historySeq == 0 && GTLogInternal.getLastMatchedEntryList().size() > 0) {
                GTLogInternal.setLastMatchedSeq(GTLogInternal.getLastMatchedEntryList().size() - 1);
                listView.setSelection(GTLogInternal.getLastMatchedEntryList().get(GTLogInternal.getLastMatchedEntryList().size() - 1).posionInDataSet);
                tv_count.setText(GTLogInternal.getLastMatchedEntryList().size() + " / " + GTLogInternal.getLastMatchedEntryList().size());
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        // 这个刷新需要在UI线程排队,否则会被listView.setSelection方法冲突掉
                        arrayAdapter.notifyDataSetChanged();
                    }
                });
            }
        }
    });
    btn_next.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            int historySeq = GTLogInternal.getLastMatchedSeq();
            if (historySeq < GTLogInternal.getLastMatchedEntryList().size() - 1) {
                GTLogInternal.setLastMatchedSeq(historySeq + 1);
                listView.setSelection(GTLogInternal.getLastMatchedEntryList().get(historySeq + 1).posionInDataSet);
                int viewSeq = historySeq + 2;
                tv_count.setText(// 这里注意显示序号要比存储位置多1,因为从1开始算
                viewSeq + " / " + GTLogInternal.getLastMatchedEntryList().size());
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        // 这个刷新需要在UI线程排队,否则会被listView.setSelection方法冲突掉
                        arrayAdapter.notifyDataSetChanged();
                    }
                });
            } else if (historySeq == GTLogInternal.getLastMatchedEntryList().size() - 1) {
                GTLogInternal.setLastMatchedSeq(0);
                listView.setSelection(GTLogInternal.getLastMatchedEntryList().get(0).posionInDataSet);
                tv_count.setText(// 这里注意显示序号要比存储位置多1,因为从1开始算
                1 + " / " + GTLogInternal.getLastMatchedEntryList().size());
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        // 这个刷新需要在UI线程排队,否则会被listView.setSelection方法冲突掉
                        arrayAdapter.notifyDataSetChanged();
                    }
                });
            }
        }
    });
    // 准备日志列表数据
    listView = (ListView) findViewById(R.id.log_search_list);
    Intent intent = getIntent();
    String openFileName = intent.getStringExtra("openFileName");
    if (openFileName == null) {
        // 日志列表
        dataSet = GTLogInternal.getCurFilteredLogs();
        arrayAdapter = new SearchLogAdapter(this, dataSet);
        listView.setAdapter(arrayAdapter);
    } else // 打开历史日志
    {
        openLog(openFileName);
    }
}
Also used : SearchLogAdapter(com.tencent.wstt.gt.log.SearchLogAdapter) OnTouchListener(android.view.View.OnTouchListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Handler(android.os.Handler) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) LinkedList(java.util.LinkedList) MotionEvent(android.view.MotionEvent) KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener)

Aggregations

OnItemClickListener (android.widget.AdapterView.OnItemClickListener)142 AdapterView (android.widget.AdapterView)141 View (android.view.View)140 ListView (android.widget.ListView)107 TextView (android.widget.TextView)74 Intent (android.content.Intent)44 ImageView (android.widget.ImageView)44 OnClickListener (android.view.View.OnClickListener)26 Bundle (android.os.Bundle)18 ArrayAdapter (android.widget.ArrayAdapter)17 SuppressLint (android.annotation.SuppressLint)15 LayoutInflater (android.view.LayoutInflater)13 Paint (android.graphics.Paint)12 GridView (android.widget.GridView)12 ColorDrawable (android.graphics.drawable.ColorDrawable)11 DialogInterface (android.content.DialogInterface)10 CheckBox (android.widget.CheckBox)9 LinearLayout (android.widget.LinearLayout)9 ArrayList (java.util.ArrayList)8 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)6