Yoctopuce Yocto-I2C Mode D'emploi page 117

Table des Matières

Publicité

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.yoctopuce.YoctoAPI.YAPI;
import com.yoctopuce.YoctoAPI.YAPI_Exception;
import com.yoctopuce.YoctoAPI.YModule;
public class
SaveSettings
{
private ArrayAdapter<String> aa;
private
YModule
@Override
public
void
onCreate(Bundle
{
super.onCreate(savedInstanceState);
setContentView(R.layout.savesettings);
Spinner my_spin
my_spin.setOnItemSelectedListener(this);
aa
= new
ArrayAdapter<String>(this,
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
my_spin.setAdapter(aa);
}
@Override
protected
void
{
super.onStart();
try {
aa.clear();
YAPI.EnableUSBHost(this);
YAPI.RegisterHub("usb");
YModule
while
String
aa.add(hwid);
r
}
} catch
(YAPI_Exception
e.printStackTrace();
}
// refresh Spinner with detected relay
aa.notifyDataSetChanged();
}
@Override
protected
void
{
super.onStop();
YAPI.FreeAPI();
}
private
void
DisplayModuleInfo()
{
TextView
field;
if
(module
return;
try {
YAPI.UpdateDeviceList();// fixme
field
field.setText(module.getLogicalName());
} catch
(YAPI_Exception
e.printStackTrace();
}
}
@Override
public
void
onItemSelected(AdapterView<?>
www.yoctopuce.com
extends
Activity
module
= null;
savedInstanceState)
= (Spinner) findViewById(R.id.spinner1);
onStart()
r
= YModule.FirstModule();
(r
!= null) {
hwid
= r.get_hardwareId();
= r.nextModule();
e) {
onStop()
== null)
= (TextView) findViewById(R.id.logicalnamefield);
e) {
14. Utilisation du Yocto-I2C avec Android
implements
OnItemSelectedListener
android.R.layout.simple_spinner_item);
parent,
View
view,
int
pos,
long
id)
109

Publicité

Table des Matières
loading

Table des Matières