Yoctopuce Yocto-Serial Mode D'emploi page 147

Table des Matières

Publicité

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<?>
{
String
hwid
module
= YModule.FindModule(hwid);
DisplayModuleInfo();
}
@Override
public
void
onNothingSelected(AdapterView<?> arg0)
{
}
public
void
saveName(View
{
if
(module
return;
EditText edit
String
newname
try {
if (!YAPI.CheckLogicalName(newname)) {
Toast.makeText(getApplicationContext(),
Toast.LENGTH_LONG).show();
www.yoctopuce.com
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) {
= parent.getItemAtPosition(pos).toString();
view)
== null)
= (EditText) findViewById(R.id.newname);
= edit.getText().toString();
19. Utilisation du Yocto-Serial avec Android
android.R.layout.simple_spinner_item);
parent,
View
view,
"Invalid name ("
int
pos,
long
id)
+
newname
+
")",
141

Publicité

Table des Matières
loading

Table des Matières