我创建了一个listview,并想知道如何让每个diff。项目打开差异。活动/意图 例如:在列表视图 -start之旅(它会抢了GPS定位数据发送到服务器马上和确认其已发送)Android:如何让listview中的项目打开diff。活动/意图
- 时钟在(它会抢时间/日期数据和发送到服务器的时候了,并确认其已发送)
- 客户SVC(意向条形码扫描仪和返回结果没有显示发送结果数据发送给服务器
马上) 非依赖性检查(意向到条形码扫描器并返回结果无显示并将结果数据发送到
服务器马上) -pick向上(意向条形码扫描仪和返回结果没有显示和结果数据发送到服务器右
远)
-Log了(它会要求输入密码才能完成注销)
即将使用项目2.2与sdk 3即将使用1.5固件设备motorola i1。我导入了zxing条码
扫描仪“android integration”到应该单独打开条码扫描器应用程序的项目。我正在使用eclipse。最后一件事我得到了resultTxt错误,并想知道如何解决这个问题?
感谢 美林
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/selection"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"/>
</LinearLayout>
Customer.java
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class Customer extends ListActivity
{
TextView selection;
String[] items = { "Start Trip", "Clock in", "Customer Svc",
"Independent Inspection", "Pick Up", "Log Out" };
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>(
this, android.R.layout.simple_list_item_1, items));
selection = (TextView) findViewById(R.id.selection);
}
public void onListItemClick(ListView parent, View v, int position, long id)
{
Intent intent = new Intent("com.company.merrill.IntentIntegrator");
intent.setPackage("com.company.merrill");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
if (requestCode == 0)
{
if (resultCode == RESULT_OK)
{
// contents contains whatever the code was
String contents = intent.getStringExtra("SCAN_RESULT");
// Format contains the type of code i.e. UPC, EAN, QRCode etc...
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
// Handle successful scan. In this example
// I just put the results into the TextView
resultsTxt.setText(format + "\n" + contents);
}
else if (resultCode == RESULT_CANCELED)
{
// Handle cancel. If the user presses 'back'
// before a code is scanned.
resultsTxt.setText("Canceled");
}
}
}
}
是什么resultsTxt?它在哪里宣布?初始化? – rekaszeru 2011-05-13 16:25:46
它来自代码示例,假设它可能是导入的类的一部分。 – merrill 2011-05-13 17:21:05
如果它没有在任何地方声明,那么在你使用它的行上必须有编译错误。根据它的名称和'setText'的用法,它可能是一个'TextView'实例,但它必须在某处(全局或在'onActivityResult'方法内)声明和初始化,就像'final TextView resultsTxt =( TextView)findViewById(R.id.results_txt);' – rekaszeru 2011-05-13 17:26:00