private void addListener() { leftLv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { listener.onSelectLeft(curPageType, popupWindowPosition, position); // initNameLeft = dataListLeft.get(position).toString();//记录当前选中的内容 leftPositionIsChange = (curPositionLeft == position) ? false : true; // 记录左侧位置是否变化 curPositionLeft = position; // leftLv.getAdapter().getView(position, view, parent).setSelected(true); // parent.getAdapter().getView(position, view, // parent).setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0)); // parent.getAdapter().getView(position, view, parent); leftAdapter.notifyDataSetChanged(); } }); rightLv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { listener.onSelectRight(curPageType, popupWindowPosition, position); // initNameRight = dataListRight.get(position).toString();//记录当前选中的内容 curPositionRight = position; // 记录当前选中的位置 curNameRight = dataListRight.get(position).toString(); // 记录当前选中的内容 dismiss(); } }); }
private void initData() { // 初使化设备存储数组 mPairedDevicesAdapter = new DeviceListAdapter(DeviceListActivity.this, pairedDevices); mNewDevicesAdapter = new DeviceListAdapter(DeviceListActivity.this, newDevices); // 设置已配队设备列表 lv_paired_devices.setAdapter(mPairedDevicesAdapter); lv_paired_devices.setOnItemClickListener(mDeviceClickListener); // 设置新查找设备列表 lv_new_devices.setAdapter(mNewDevicesAdapter); lv_new_devices.setOnItemClickListener(mDeviceClickListener); // 注册接收查找到设备action接收器 IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothDevice.ACTION_FOUND); filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); this.registerReceiver(mReceiver, filter); // 得到本地蓝牙句柄 mBtAdapter = BluetoothAdapter.getDefaultAdapter(); // 得到已配对蓝牙设备列表 Set<BluetoothDevice> bondedDevices = mBtAdapter.getBondedDevices(); // 添加已配对设备到列表并显示 if (bondedDevices.size() > 0) { tv_paired_devices.setVisibility(View.VISIBLE); for (BluetoothDevice device : bondedDevices) { mPairedDevicesAdapter.add(device); } } }
private void initAction() { ListView fab = (ListView) findViewById(R.id.query_history_favorite); fab.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { QueryHistoryListItem item = (QueryHistoryListItem) parent.getItemAtPosition(position); Intent result = new Intent(); result.putExtra(EXTRA_KEY_TRANSIT_QUERY, item.getQuery()); setResult(RESULT_CODE_ROUTE_SELECTED, result); finish(); } }); registerForContextMenu(fab); ListView all = (ListView) findViewById(R.id.query_history_all); all.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { QueryHistoryListItem item = (QueryHistoryListItem) parent.getItemAtPosition(position); Intent result = new Intent(); result.putExtra(EXTRA_KEY_TRANSIT_QUERY, item.getQuery()); setResult(RESULT_CODE_ROUTE_SELECTED, result); finish(); } }); registerForContextMenu(all); ListView location = (ListView) findViewById(R.id.query_history_location); registerForContextMenu(location); }
private void init() { this.btAdd = (Button) findViewById(R.id.btAdd); this.etNombre = (EditText) findViewById(R.id.etNombre); this.etInstruccion = (EditText) findViewById(R.id.etInstruccion); this.img = (ImageView) findViewById(R.id.iv); this.lv = (ListView) findViewById(R.id.lvAlta); this.rg = (RadioGroup) findViewById(R.id.radiogroup); this.rbCarne = (RadioButton) findViewById(R.id.rbCarne); this.rbPescado = (RadioButton) findViewById(R.id.rbPescado); this.rbPostre = (RadioButton) findViewById(R.id.rbPostre); this.lvu = (ListView) findViewById(R.id.lvUtensilios); btAdd = (Button) findViewById(R.id.btElegir); listaingre = new ArrayList<>(); gp = new GestorReceta(this); gpi = new GestorIngrediente(this); gri = new GestorRecetaIngrediente(this); gpu = new GestorUtensilio(this); r = new Receta(); r.setNombre(getIntent().getExtras().getString("nombre")); r.setFoto(getIntent().getExtras().getString("foto")); r.setId_categoria(getIntent().getExtras().getLong("cat")); r.setInstrucciones(getIntent().getExtras().getString("instrucciones")); r.setId(getIntent().getExtras().getLong("id")); img.setImageURI(Uri.parse(r.getFoto())); etNombre.setText(r.getNombre()); etInstruccion.setText(r.getInstrucciones()); gpi.open(); c = gpi.getCursor(); adp = new AdaptadorIngredientes(this, c); lv.setAdapter(adp); lv.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { tostada(c.getString(1) + " ha sido añadido"); listaingre.add(c); } }); gpi.close(); gpu.open(); c2 = gpu.getCursor(); adpu = new AdaptadorUtensilios(this, c2); lvu.setAdapter(adpu); lvu.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {} }); gpu.close(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getSherlockActivity().getSupportActionBar().setTitle(mTitle); View v = inflater.inflate(R.layout.audio_albums_songs, container, false); mTabHost = (TabHost) v.findViewById(android.R.id.tabhost); ListView albumsList = (ListView) v.findViewById(R.id.albums); ListView songsList = (ListView) v.findViewById(R.id.songs); mFlingViewGroup = (FlingViewGroup) v.findViewById(R.id.fling_view_group); songsList.setAdapter(mSongsAdapter); albumsList.setAdapter(mAlbumsAdapter); songsList.setOnItemClickListener(songsListener); albumsList.setOnItemClickListener(albumsListener); registerForContextMenu(albumsList); registerForContextMenu(songsList); mTabHost.setup(); addNewTab(mTabHost, "albums", "Albums"); addNewTab(mTabHost, "songs", "Songs"); mTabHost.setCurrentTab(mCurrentTab); mFlingViewGroup.snapToScreen(mCurrentTab); mTabHost.setOnTabChangedListener( new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { mCurrentTab = mTabHost.getCurrentTab(); mFlingViewGroup.smoothScrollTo(mCurrentTab); } }); mFlingViewGroup.setOnViewSwitchedListener( new FlingViewGroup.ViewSwitchListener() { @Override public void onSwitching(float progress) {} @Override public void onSwitched(int position) { mTabHost.setCurrentTab(position); } @Override public void onTouchDown() {} @Override public void onTouchUp() {} @Override public void onTouchClick() {} }); return v; }
public void setListView() { ListView lv; SimpleAdapter sa; final Context _c = this; // temp lv = (ListView) findViewById(R.id.lvoften); sa = new SimpleAdapter( this, al_often, R.layout.view_smalltext, new String[] {"name"}, new int[] {R.id.text}); lv.setAdapter(sa); lv.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Activity_SongInfo.songinfo_uri = pp.al_often_ps.get(arg2).pageuri; startActivity(new Intent(_c, Activity_SongInfo.class)); } }); lv = (ListView) findViewById(R.id.lvrecent); sa = new SimpleAdapter( this, al_recent, R.layout.view_smalltext, new String[] {"name"}, new int[] {R.id.text}); lv.setAdapter(sa); lv.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Activity_SongInfo.songinfo_uri = pp.al_recent_ps.get(arg2).pageuri; startActivity(new Intent(_c, Activity_SongInfo.class)); } }); // label event TextView tv; tv = (TextView) findViewById(R.id.textView2); tv.setOnClickListener( new OnClickListener() { public void onClick(View v) { Activity_PlayList.user_id = user_id; Activity_PlayList.user_name = user_name; Activity_PlayList.uri_source = "http://www.dream-pro.info/~lavalse/LR2IR/search.cgi?mode=mylist&sort=recent&playerid=" + user_id; startActivity(new Intent(_c, Activity_PlayList.class)); } }); tv = (TextView) findViewById(R.id.textView3); tv.setOnClickListener( new OnClickListener() { public void onClick(View v) { Activity_PlayList.user_id = user_id; Activity_PlayList.user_name = user_name; Activity_PlayList.uri_source = "http://www.dream-pro.info/~lavalse/LR2IR/search.cgi?mode=mylist&sort=playcount&playerid=" + user_id; startActivity(new Intent(_c, Activity_PlayList.class)); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set up the window setContentView(R.layout.device_list); // set result cancelled in case user backs out setResult(Activity.RESULT_CANCELED); // initialize button to perform device discovery Button scanButton = (Button) findViewById(R.id.button_scan); scanButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { doDiscovery(); v.setVisibility(View.GONE); } }); // initialize array adapters. one for already paired, and one for new mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name); mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name); // find and set up listview for paired ListView pairedListView = (ListView) findViewById(R.id.paired_devices); pairedListView.setAdapter(mPairedDevicesArrayAdapter); pairedListView.setOnItemClickListener(mDeviceClickListener); // find and set up listview for newly discovered devices ListView newDevicesListView = (ListView) findViewById(R.id.new_devices); newDevicesListView.setAdapter(mNewDevicesArrayAdapter); newDevicesListView.setOnItemClickListener(mDeviceClickListener); // register for broadcast when device is discovered IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); this.registerReceiver(mReceiver, filter); // reigster for boardcasts when discovery is finished filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); this.registerReceiver(mReceiver, filter); // get local adapter mBtAdapter = BluetoothAdapter.getDefaultAdapter(); // get a set of currently paired devices Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices(); // if there are paired devices add to arrayadapter if (pairedDevices.size() > 0) { findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE); for (BluetoothDevice device : pairedDevices) { mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); } } else { String noDevices = getResources().getText(R.string.none_paired).toString(); mPairedDevicesArrayAdapter.add(noDevices); } }
private void loadFileNames() { listView.setOnItemClickListener(null); fileNames.clear(); File[] files = getPhotoFilesFromDirectory(); for (int i = 0; i < files.length; i++) fileNames.add(files[i].getAbsolutePath()); listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, fileNames)); listView.setOnItemClickListener(this); }
private void InitUI() { TextView leftButton = (TextView) findViewById(R.id.left_text); leftButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { setResult(RESULT_CANCELED); finish(); } }); TextView rightButton = (TextView) findViewById(R.id.right_text); rightButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent data = new Intent(); data.putExtra(KEY_CALENDAR_ID, calendarID); setResult(RESULT_OK, data); finish(); } }); calendarNameTextView = (TextView) findViewById(R.id.calendar_name_text); calendarDescTextView = (TextView) findViewById(R.id.calendar_desc_text); ImageView imageView = (ImageView) findViewById(R.id.arrow_icon); imageView.setImageResource(R.drawable.schedule_calendar_arrow_up); calendarList = (ListView) findViewById(R.id.calendar_list); calendarList.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {} }); calendarList.setAdapter(new LocationAdapter(this)); calendarList.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { calendarID = id; Calendar365 item = (Calendar365) parent.getItemAtPosition(position); update(item); ((LocationAdapter) parent.getAdapter()).notifyDataSetChanged(); } }); CalendarManager calendarManager = new CalendarManager(this); update(calendarManager.findCalendar(calendarID)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.devicelist); setResult(Activity.RESULT_CANCELED); m_knownDeviceLabel = (TextView) findViewById(R.id.PairedDeviceLabel); m_knownDeviceList = (ListView) findViewById(R.id.PairedDeviceList); m_foundDeviceList = (ListView) findViewById(R.id.FoundDeviceList); m_scanWaitMarker = (LinearLayout) findViewById(R.id.WaitLayoutGroup); m_scanWaitText = (TextView) findViewById(R.id.WaitLabelText); m_scanButton = (Button) findViewById(R.id.ScanButton); registerReceiver( discoveryStartedMonitor, new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED)); registerReceiver( discoveryFinishedMonitor, new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)); registerReceiver(deviceFoundMonitor, new IntentFilter(BluetoothDevice.ACTION_FOUND)); registerReceiver( deviceBondedMonitor, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); m_bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (m_bluetoothAdapter == null) { AlertDialog dlg = new AlertDialog.Builder(this).create(); dlg.setMessage("No bluetooth device found"); dlg.show(); return; } ArrayList<BluetoothDevice> devices = new ArrayList<BluetoothDevice>(m_bluetoothAdapter.getBondedDevices()); m_knownDeviceList.setAdapter(new DeviceItemAdapter(this, R.layout.devicelist_item, devices)); if (devices.size() == 0) { m_knownDeviceLabel.setVisibility(View.GONE); m_knownDeviceList.setVisibility(View.GONE); } m_foundDevices = new ArrayList<BluetoothDevice>(); m_foundDeviceList.setAdapter( new DeviceItemAdapter(this, R.layout.devicelist_item, m_foundDevices)); m_knownDeviceList.setOnItemClickListener(onDeviceClick); m_foundDeviceList.setOnItemClickListener(onDeviceClick); m_scanButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { discoverDevices(); } }); discoverDevices(); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.device_list); setTitle(R.string.select_device); bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); Button scanButton = (Button) findViewById(R.id.button_scan); scanButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { doDiscovery(); v.setVisibility(View.GONE); } }); mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name); mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name); ListView pairedListView = (ListView) findViewById(R.id.paired_devices); pairedListView.setAdapter(mPairedDevicesArrayAdapter); pairedListView.setOnItemClickListener(this); ListView newListView = (ListView) findViewById(R.id.new_devices); newListView.setAdapter(mNewDevicesArrayAdapter); newListView.setOnItemClickListener(this); if (bluetoothAdapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); finish(); return; } Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices(); if (pairedDevices.size() > 0) { findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE); for (BluetoothDevice device : pairedDevices) { mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); } } else { findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE); String noDevices = getResources().getText(R.string.none_paired).toString(); mPairedDevicesArrayAdapter.add(noDevices); } mPairedDevicesArrayAdapter.notifyDataSetChanged(); IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); this.registerReceiver(receiver, filter); filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); this.registerReceiver(receiver, filter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // init views right = (ListView) findViewById(R.id.rightList); left = (ListView) findViewById(R.id.leftList); // init DAL dal = new AppEntryTimeDAL(this); // add time entry String time = DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()); dal.addEntryTime(time); Log.d(TAG, time); // array adapter final ArrayList<String> list = dal.getAllEntryTimesList(); arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, list); right.setAdapter(arrayAdapter); right.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String time = list.get(position); Toast.makeText(view.getContext(), time, Toast.LENGTH_SHORT).show(); } }); // Cursor adapter String[] columns = new String[] {AppEntryTimeContract.AppEntryTime.ENTRY_TIME}; int[] viewsID = new int[] {android.R.id.text1}; cursor = dal.getAllEntryTimesCursor(); cursorAdapter = new SimpleCursorAdapter( this, android.R.layout.simple_list_item_1, cursor, columns, viewsID, 0); left.setAdapter(cursorAdapter); left.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (cursor.moveToPosition(position)) { int timeIndex = cursor.getColumnIndex(AppEntryTimeContract.AppEntryTime.ENTRY_TIME); String time = cursor.getString(timeIndex); Toast.makeText(view.getContext(), time, Toast.LENGTH_SHORT).show(); } } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); Bundle extras = getIntent().getExtras(); if (extras != null) idUser = (int) extras.getLong("idUser"); categoryAdapter = new CategoryListAdapter(this); projectAdapter = new ProjectListAdapter(this); lvCategories = (ListView) findViewById(R.id.lvCategories); lvCategories.setAdapter(categoryAdapter); lvCategories.setClickable(true); lvProjects = (ListView) findViewById(R.id.lvProjects); lvProjects.setAdapter(projectAdapter); lvProjects.setClickable(true); categoryService = new CategoryService(); categories = categoryService.getAllCategories(); for (Category c : categories) categoryAdapter.add(c); projectService = new ProjectService(); projects = projectService.getAllProjects(); for (Project p : projects) projectAdapter.add(p); lvCategories.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { projectAdapter.removeAll(); projectsByCategory = projectService.getProjectsByCategory(position + 1); for (Project p : projectsByCategory) projectAdapter.add(p); } }); lvProjects.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent_ListProjectProjectbyId = new Intent(ListProject.this, ProjectbyId.class); Intent_ListProjectProjectbyId.putExtra("idProject", position + 1); Intent_ListProjectProjectbyId.putExtra("idUser", idUser); startActivity(Intent_ListProjectProjectbyId); } }); }
@Override protected void onStart() { // TODO Auto-generated method stub super.onStart(); getPairedDevices(); buttonOn.setOnClickListener(clicked); buttonSearch.setOnClickListener(clicked); buttonDesc.setOnClickListener(clicked); buttonOff.setOnClickListener(clicked); listViewDetected.setOnItemClickListener(listItemClicked); listViewPaired.setOnItemClickListener(listItemClickedonPaired); }
protected void onCreate(final Bundle pSavedInstanceState) { super.onCreate(pSavedInstanceState); this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); this.setContentView(R.layout.list_bluetooth_devices); // Set result CANCELED in case the user backs out this.setResult(Activity.RESULT_CANCELED); final Button scanButton = (Button) this.findViewById(R.id.button_scan); scanButton.setOnClickListener( new View.OnClickListener() { public void onClick(final View v) { BluetoothListDevicesActivity.this.discoverBluetoothDevices(); v.setVisibility(View.GONE); } }); this.mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); this.mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); final ListView pairedListView = (ListView) this.findViewById(R.id.paired_devices); pairedListView.setAdapter(this.mPairedDevicesArrayAdapter); pairedListView.setOnItemClickListener(this.mDeviceClickListener); final ListView newDevicesListView = (ListView) this.findViewById(R.id.new_devices); newDevicesListView.setAdapter(this.mNewDevicesArrayAdapter); newDevicesListView.setOnItemClickListener(this.mDeviceClickListener); // Register for broadcasts when a device is discovered IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); this.registerReceiver(this.mReceiver, filter); // Register for broadcasts when discovery has finished filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); this.registerReceiver(this.mReceiver, filter); this.mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // Get a set of currently paired devices final Set<BluetoothDevice> pairedDevices = this.mBluetoothAdapter.getBondedDevices(); if (pairedDevices.size() > 0) { this.findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE); for (final BluetoothDevice device : pairedDevices) { this.mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); } } else { this.mPairedDevicesArrayAdapter.add("No devices have been paired!"); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.device_list); setResult(Activity.RESULT_CANCELED); Button scanButton = (Button) findViewById(R.id.button_scan); scanButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { doDiscovery(); v.setVisibility(View.GONE); } }); mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name); mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name); ListView pairedListView = (ListView) findViewById(R.id.paired_devices); pairedListView.setAdapter(mPairedDevicesArrayAdapter); pairedListView.setOnItemClickListener(mDeviceClickListener); ListView newDevicesListView = (ListView) findViewById(R.id.new_devices); newDevicesListView.setAdapter(mNewDevicesArrayAdapter); newDevicesListView.setOnItemClickListener(mDeviceClickListener); IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); this.registerReceiver(mReceiver, filter); filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); this.registerReceiver(mReceiver, filter); mBtAdapter = BluetoothAdapter.getDefaultAdapter(); Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices(); boolean empty = true; if (pairedDevices.size() > 0) { for (BluetoothDevice device : pairedDevices) { if ((device.getBluetoothClass() != null) && (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.TOY_ROBOT)) { mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); empty = false; } } } if (!empty) { findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE); findViewById(R.id.no_devices).setVisibility(View.GONE); } }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.dialog_fragment_configure_receiver_page_2, container, false); brandListView = (ListView) rootView.findViewById(R.id.listView_brands); brandNamesAdapter = new ArrayAdapter<>( getActivity(), android.R.layout.simple_list_item_single_choice, getResources().getStringArray(R.array.brand_array)); brandListView.setAdapter(brandNamesAdapter); brandListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { updateModelList((String) brandNamesAdapter.getItem(position)); sendBrandModelChangedBroadcast(getActivity(), getSelectedBrand(), getSelectedModel()); } }); modelTextView = (TextView) rootView.findViewById(R.id.textView_model); modelListView = (ListView) rootView.findViewById(R.id.listView_models); modelNamesAdapter = new ArrayAdapter<>( getActivity(), android.R.layout.simple_list_item_single_choice, new ArrayList<String>()); modelListView.setAdapter(modelNamesAdapter); modelListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { sendBrandModelChangedBroadcast(getActivity(), getSelectedBrand(), getSelectedModel()); } }); Bundle args = getArguments(); if (args != null && args.containsKey(ConfigureReceiverDialog.RECEIVER_ID_KEY)) { long receiverId = args.getLong(ConfigureReceiverDialog.RECEIVER_ID_KEY); initializeReceiverData(receiverId); } return rootView; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.more_category_list); class_id = MoreCategoryActivity.this.getIntent().getStringExtra("class_id"); position = MoreCategoryActivity.this.getIntent().getIntExtra("position", 0); listview1 = (ListView) findViewById(R.id.list_view1); listview2 = (ListView) findViewById(R.id.list_view2); btn_back_id = (ImageButton) findViewById(R.id.btn_back_id); adapter = new ViewMoreLeftAdapter(MoreCategoryActivity.this); adapter2 = new ViewMoreRightAdapter(MoreCategoryActivity.this); datas_parent_class = new ArrayList<CategoryList>(); datas_class_json = new ArrayList<CategoryList>(); info(position, class_id); listview1.setAdapter(adapter); listview2.setAdapter(adapter2); btn_back_id.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { MoreCategoryActivity.this.finish(); } }); listview1.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int arg2, long arg3) { CategoryList d = (CategoryList) listview1.getItemAtPosition(arg2); datas_class_json.clear(); info(arg2, d.getClass_id()); } }); listview2.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { adapter2.setSelectItem(arg2); adapter2.notifyDataSetChanged(); CategoryList d = (CategoryList) listview2.getItemAtPosition(arg2); Intent intent = new Intent(MoreCategoryActivity.this, StoreListActivity.class); intent.putExtra("class_id", d.getClass_id()); intent.putExtra("url_flag", "storeclass"); MoreCategoryActivity.this.startActivity(intent); MoreCategoryActivity.this.finish(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] osLijst = new String[] { "Android", "Iphone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Mac OS X", "Linux", "OS/2" }; ArrayAdapter<String> listViewArrayAdapter = new ArrayAdapter<String>(this, R.layout.listview_item, R.id.listViewItem, osLijst); final ListView listView = getListView(); listView.setAdapter(listViewArrayAdapter); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText( MainActivity.this, "Clicked ListItem number " + position, Toast.LENGTH_SHORT) .show(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sharing); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mProgressDialog = new ProgressDialog(SharingActivity.this); // hook up list view ListView list = (ListView) findViewById(R.id.sharingListView); mAdapter = new ToolAdapter(mSharingTools, this); list.setAdapter(mAdapter); list.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (mSharingTools.size() > i && i >= 0) { ToolItem tool = mSharingTools.get(i); // execute the sharing action if (tool.isEnabled()) { tool.getAction().run(); } else { app().showToastMessage(tool.getDisabledNotice()); } } } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_algorithm_select); algorithmArray = getResources().getStringArray(R.array.algorithm); BlurBehind.getInstance() .withAlpha(100) .withFilterColor(Color.parseColor("#686350")) .setBackground(this); algorithmListView = (ListView) findViewById(R.id.algorithm_list); ArrayAdapter<String> itemsAdapter = new ArrayAdapter<String>(this, R.layout.algorithm_list_row, algorithmArray); algorithmListView.setAdapter(itemsAdapter); algorithmListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(); intent.putExtra("algorithmName", algorithmArray[position]); intent.putExtra("algorithmId", position); setResult(RESULT_OK, intent); Log.i("algorithm ", algorithmArray[position]); finish(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar); drawerItems = getResources().getStringArray(R.array.drawerItems); drawer = (DrawerLayout) findViewById(R.id.drawerLayout); drawerList = (ListView) findViewById(R.id.left_drawer); // Set the adapter for the list view drawerList.setAdapter(new ArrayAdapter<>(this, R.layout.item_row, drawerItems)); // Set the list's click listener, and expose first view drawerList.setOnItemClickListener(new DrawerItemClickListener()); selectItem(0); drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.app_name, R.string.app_name) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); } }; drawer.setDrawerListener(drawerToggle); drawerToggle.syncState(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false); mDrawerListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { selectItem(position); } }); mDrawerListView.setAdapter( new ArrayAdapter<String>( getActionBar().getThemedContext(), android.R.layout.simple_list_item_activated_1, android.R.id.text1, new String[] { getString(R.string.title_section1), getString(R.string.title_section2), getString(R.string.title_section3), })); mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return mDrawerListView; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_daily_forecast); ButterKnife.bind(this); Intent intent = getIntent(); mLocation = intent.getStringExtra(getString(R.string.location_name)); Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.DAILY_FORECAST); mDays = Arrays.copyOf(parcelables, parcelables.length, Day[].class); mLocationLabel.setText(String.valueOf(mLocation)); DayAdapter adapter = new DayAdapter(this, mDays); mListView.setAdapter(adapter); mListView.setEmptyView(mEmptyTextView); mListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String dayOfTheWeek = mDays[position].getDayOfTheWeek(); String conditions = mDays[position].getSummary(); String highTemp = mDays[position].getTemperatureMax() + ""; String lowTemp = mDays[position].getTemperatureMin() + ""; String message = String.format( "%s - High: %s, Low: %s, and %s", dayOfTheWeek, highTemp, lowTemp, conditions); Toast.makeText(DailyForecastActivity.this, message, Toast.LENGTH_LONG).show(); } }); }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment_news, container, false); initView(); gold_button.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { settab(1); } }); world_button.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { settab(2); } }); news_list.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { adapter.setindex(position); bean = (NewsBean) adapter.getItem(position); if (isNotice) { getNotice(); } else { getAnalyze(); } } }); return view; }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO 自動生成されたメソッド・スタブ super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); // コンポーネントの関連付け layout = (RelativeLayout) this.findViewById(R.id.main_layout); listView = (ListView) this.findViewById(R.id.listView1); // リストビューのスクロールキャッシュ無効(色がおかしくなるので) listView.setScrollingCacheEnabled(false); // リスナーの設定 listView.setOnItemClickListener(this); // アダプター作成 adapter = new TaskArrayAdapter(this, setItem()); // リストビューに項目データ(アダプタ)をセット listView.setAdapter(adapter); // 何もタスクが無いのなら新規作成のダイアログが開く int i = 0; editText = new EditText(this); editText.setInputType(InputType.TYPE_CLASS_TEXT); for (int j = 0; j < 10; j++) { i += adapter.getList().get(j).getTask().length(); if (j == 9 && i == 0) { showYesDialog( ListActivity.this, "何かタスクを作ってみよう", "あなたがよく行う習慣を登録して時間を計りましょう", editText, this, 1); break; } } }
@Override protected void setListener() { btn_back.setOnClickListener(this); lv_album.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { /** * 根据position参数,可以获得跟GridView的子View相绑定的实体类,然后根据它的isSelected状态, 来判断是否显示选中效果。 * 至于选中效果的规则,下面适配器的代码中会有说明 */ /** 通知适配器,绑定的数据发生了改变,应当刷新视图 */ Object obj = lv_album.getItemAtPosition(position); if (obj instanceof ImageBucket) { ImageBucket bucket = (ImageBucket) obj; // adapter.notifyDataSetChanged(); Intent intent = new Intent(AlbumActivity.this, AlbumLsitActivity.class); Bundle bundle = new Bundle(); bundle.putString("bucket", bucket.bucketName); intent.putExtras(bundle); intent.putExtra( AlbumActivity.EXTRA_IMAGE_LIST, (Serializable) dataList.get(position).imageList); startActivityForResult(intent, 5); } } }); }
public void preencherInterface(final ArrayList<Avaliacoes> busca) { ArrayList<RowItemAvaliacao> data = new ArrayList<RowItemAvaliacao>(); Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.prancheta); for (Avaliacoes a : busca) { RowItemAvaliacao item = new RowItemAvaliacao( bmp, a.getUsuarioAluno(), a.getDataAvaliacao(), a.getHoraAvaliacao(), a.getResultado()); data.add(item); } CustomAdapterAvaliacoes adapter = new CustomAdapterAvaliacoes(getActivity(), data); lstListaAvaliacoesRealizadas.setAdapter(adapter); lstListaAvaliacoesRealizadas.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent i = new Intent(getActivity(), VisualizarAvaliacao.class); i.putExtra("codAvaliacao", busca.get(arg2).getCodAvaliacao()); startActivity(i); } }); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); AdRequest ar = new AdRequest(); ar.addTestDevice("4B605421C6EAA120E18B7FA165D2E980"); final ListView lv1 = (ListView) findViewById(R.id.listView); threadArray = new ArrayList<String>(); authorArray = new ArrayList<String>(); getDevice(); lv1.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { Object o = lv1.getItemAtPosition(position); TitleResults fullObject = (TitleResults) o; threadTitle = fullObject.getItemName(); Constants.THREADURL = threadArray.get(position); Intent intent = new Intent(MainActivity.this, ThreadActivity.class); Bundle b = new Bundle(); b.putString("title", threadTitle); intent.putExtras(b); startActivity(intent); } }); if (Constants.DEVICE != null) { ArrayList<TitleResults> titleArray = getTitles(); lv1.setAdapter(new TitleAdapter(this, titleArray)); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_details, container, false); toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); posterText = (TextView) rootView.findViewById(R.id.posterTitle); posterBar = (ImageView) rootView.findViewById(R.id.posterImage); dateText = (TextView) rootView.findViewById(R.id.release_date); durationText = (TextView) rootView.findViewById(R.id.duration); voteText = (TextView) rootView.findViewById(R.id.average_vote); overviewText = (TextView) rootView.findViewById(R.id.overview); trailerListView = (ListView) rootView.findViewById(R.id.trailerListView); trailerListView.setOnItemClickListener(this); reviewListView = (ListView) rootView.findViewById(R.id.reviewListView); trailerLinear = (LinearLayout) rootView.findViewById(R.id.trailer_linear); reviewLinear = (LinearLayout) rootView.findViewById(R.id.review_linear); toggleBtn = (ToggleButton) rootView.findViewById(R.id.toggle); toggleBtn.setOnClickListener(this); Log.i("isNull", getArguments() == null ? "ok" : "no"); if (toolbar != null) { // onePane Mode ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); try { ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } catch (NullPointerException e) { e.printStackTrace(); } } curd = new CURD(getActivity(), movie); return rootView; }