Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 (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
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
<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>
Posted
Comments
Richard MacCutchan 28-Oct-15 5:18am    
I do not see any code where you set the values of your spinners or text boxes. You get the individual items from the database but then ignore the returned values so they do not get place anywhere.

1 solution

See Handling Input and Storage on Android[^], an excellent article by Peter Leow[^] with lots of sample code to help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900