mardi 27 octobre 2015

Why no information display on my textview and spinner

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_content"
                    android:layout_height="wrap_content"
                    android:textColor="#000000"
                    android:text="@string/Description"
                    android:id="@+id/text"
                    android:textStyle="bold"/>
                <TextView
                    android:layout_width="250dp"
                    android:layout_height="wrap_content"
                    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_content"
                    android:layout_height="wrap_content"
                    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:popupBackground="#FFFF99"
                    />
            </TableRow>
            <TableRow
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_margin="10dp">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    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:popupBackground="#FFFF99"/>

            </TableRow>
            <TableRow
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_margin="10dp">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    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_content"
                    android:layout_height="wrap_content"
                    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_content"
                    android:layout_height="wrap_content"
                    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:onClick="rateDesign"
                    android:id="@+id/rd" />
            </TableRow>
        </TableLayout>
    </ScrollView>
</LinearLayout>

Aucun commentaire:

Enregistrer un commentaire