私はAndroidでプログラミングするのが比較的新しく、リストの項目をクリックして2つのデバイスをペアにする方法を理解できません新しく発見されたデバイス。リストビューの項目をクリックして2つのBluetoothデバイスをペア設定すると、
は、私はすでに、新たに発見されたデバイスのセットを含むリストビューを作成し、ここでのクリックイベントのために私のコードの一部ですしました: `
public class MainActivity extends AppCompatActivity {
ListView newListView; // listView containing newly discovered devices
ArrayAdapter<String> mNewDevicesArrayAdapter;
BluetoothAdapter mBluetoothAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
/* Variables definition */
mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
newListView = (ListView) findViewById(R.id.new_lv);
// New Devices List View item click
newListView.setClickable(true);
newListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// some code must go here, but I can't figure out which one
}
});
}
おかげで、事前にあなたの助けのために!
the documentationにありますか?このコードはあなたが表示している限り、空のアダプタを持っています –
[Androidのlistviewの項目をクリックしてBluetoothデバイスを接続する方法は?](http://stackoverflow.com/questions/19132160/howブルートゥースデバイスをクリックしてリストビューインアンドロイドに接続する) –
発見されたBluetoothデバイスのリストは「newListView」に保存されていますが、この新たに発見されたデバイス(newListViewからアイテムをクリックして選択したもの)とBluetoothAdapterをペアにするために、BluetoothDeviceのインスタンスを作成します。 –