为什么我的textview和微调器上没有显示信息 [英] Why no information display on my textview and spinner
问题描述
为什么我的NearablesDemoActivity.java上没有信息显示?我使用sqlite创建了数据库。我已经使用我在playstore中下载的asqlitemanager输入了id,identifier,description,size available ....进入数据库文件但是ListNearablesActivity.java上没有显示任何内容。假设贴纸(estimote nearables)正在移动,它将显示NearablesDemoActivity.java。我有谷歌,没有什么似乎是太多的帮助。有人请帮帮我........
NearablesDemoActivity.java
Why is there no information display on my NearablesDemoActivity.java? I created the database using sqlite. I have entered the id, identifier, description, size available.... into the database file using asqlitemanager I have downloaded in the playstore but there's nothing displayed on ListNearablesActivity.java. Supposed the sticker (estimote nearables) is moving, it will display NearablesDemoActivity.java. I have google and nothing seems to be too much of a help. Someone please help me ........
NearablesDemoActivity.java
private void displayCurrentNearableInfo() {
Desc = (TextView) findViewById(R.id.textview1); //for description
// Get reference of SpinnerView from layout/nearable_demo.xml
spinnerDropDown = (Spinner) findViewById(R.id.spinner1); //For size available
spinnerDropDown2 = (Spinner) findViewById(R.id.spinner2);//for colours available
COO = (TextView) findViewById(R.id.textview2);//for country of origin
SM = (TextView) findViewById(R.id.textview3); //for shoe model
Price = (TextView) findViewById(R.id.textview4); //for price
stickerdb = new Database_sticker(this);
dbRow = stickerdb.getResult(currentNearable.identifier);
dbRow.getId();
dbRow.getIdentifier();
dbRow.getDesc();
dbRow.getSa();
dbRow.getCa();
dbRow.getCoo();
dbRow.getSm();
dbRow.getPrice();
}
ListNearablesActivity.java(点击后会转到NearablesDemoActivity.java)
ListNearablesActivity.java (When click will go to NearablesDemoActivity.java)
private AdapterView.OnItemClickListener createOnItemClickListener() {
return new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
if (getIntent().getStringExtra(EXTRAS_TARGET_ACTIVITY) != null){
try {
Class<?> clazz = Class.forName(getIntent().getStringExtra(EXTRAS_TARGET_ACTIVITY));
Intent intent = new Intent(ListNearablesActivity.this, clazz);
intent.putExtra(EXTRAS_NEARABLE, adapter.getItem(position));
startActivity(intent);
} //close for try
catch (ClassNotFoundException e) {
Log.e(TAG, "Finding class by name failed", e);
} //close for catch (ClassNotFoundException e)
} //close for getintent.getStringExtra()
} //close for public void onitemclick
}; //close for return new adapterview
} //close for private adapter
Database_sticker.java
Database_sticker.java
public Sresult getResult(String identifier) {
String selectQuery = "SELECT * FROM " + TABLE_SRESULT + " WHERE " + KEY_IDENTIFIER + "='" + identifier + "'";
SQLiteDatabase db = this.getWritableDatabase(); //open database
Cursor cursor = db.rawQuery(selectQuery, null);
//looping through all rows and adding to list
Sresult sresult = new Sresult();
if (cursor.moveToFirst()) {
do {
sresult.setId(Integer.parseInt(cursor.getString(0)));
sresult.setIdentifier(cursor.getString(1));
sresult.setDesc(cursor.getString(2));
sresult.setSa(cursor.getString(3));
sresult.setCa(cursor.getString(4));
sresult.setCoo(cursor.getString(5));
sresult.setSm(cursor.getString(6));
sresult.setPrice(Float.parseFloat(cursor.getString(7)));
} while (cursor.moveToNext());
}
return sresult;
}
nearable_demo.xml
nearable_demo.xml
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_removed"
android:layout_height="wrap_removed"
android:textColor="#000000"
android:text="@string/Description"
android:id="@+id/text"
android:textStyle="bold"/>
<TextView
android:layout_width="250dp"
android:layout_height="wrap_removed"
android:textColor="#000000"
android:textStyle="italic"
android:id="@+id/textview1"
/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_removed"
android:layout_height="wrap_removed"
android:textColor="#000000"
android:text="@string/SA"
android:textStyle="bold"
android:id="@+id/text2"
/>
<Spinner
android:id="@+id/spinner1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:popupremoved="#FFFF99"
/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_removed"
android:layout_height="wrap_removed"
android:textColor="#000000"
android:text="@string/CA"
android:textStyle="bold"
android:id="@+id/text3"/>
<Spinner
android:id="@+id/spinner2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:popupremoved="#FFFF99"/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_removed"
android:layout_height="wrap_removed"
android:textColor="#000000"
android:text="@string/COO"
android:id="@+id/text4"
android:textStyle="bold"/>
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:textColor="#000000"
android:id="@+id/textview2" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_removed"
android:layout_height="wrap_removed"
android:textColor="#000000"
android:text="@string/SM"
android:id="@+id/text5"
android:textStyle="bold"/>
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:textColor="#000000"
android:id="@+id/textview3" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_removed"
android:layout_height="wrap_removed"
android:textColor="#000000"
android:text="@string/Price"
android:id="@+id/text6"
android:textStyle="bold"/>
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textview4" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/RD"
android:/>
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>
推荐答案
参见在Android上处理输入和存储 [ ^ ], Peter Leow [ ^ ]有很多示例代码可以帮助您。
See Handling Input and Storage on Android[^], an excellent article by Peter Leow[^] with lots of sample code to help you.
这篇关于为什么我的textview和微调器上没有显示信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!