Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:29:22+00:00 2026-06-03T14:29:22+00:00

I have a database that has three columns Maker, Model and Price and I

  • 0

I have a database that has three columns Maker, Model and Price and I have made it so that when a button is pressed to store everything in a string and pass the string to a TextView. The idea is that I want to somehow make the text clickable and when the text is clicked for a given product to store the price of the product in a variable.

This is the code for displaying everything in the database

    package com.WareHouse;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class viewall extends Activity {

SQLiteDatabase myDB = null;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.vall);

    Button vAll = (Button) findViewById(R.id.viewAll);
    final TextView view2 = (TextView) findViewById(R.id.multiAutoCompleteTextView1);

    vAll.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            try {
                String Data = "";

                String TableName = "myTable";

                myDB = getBaseContext().openOrCreateDatabase(
                        "DatabaseName", MODE_PRIVATE, null);

                Cursor c = myDB
                        .rawQuery("SELECT * FROM " + TableName, null);

                int Column1 = c.getColumnIndex("Field1");
                int Column2 = c.getColumnIndex("Field2");
                                    int Column3 = c.getColumnIndex("Field3");

                // Check if our result was valid.
                c.moveToFirst();
                if (c != null) {
                    // Loop through all Results
                    do {
                        String Name = c.getString(Column1);
                        String Model = c.getString(Column2);
                                                    String Price = c.getStrin(Column3);
                        Data = Data + "Maker: " + Name + "\n" + "Model: "
                                + Model + "\n" +"Price: " + Price+ "\n"+"\n";
                    } while (c.moveToNext());

                }
                //////////////////////////////////////////
                view2.setText(Data.toString());
            } catch (Exception e) {
                Log.e("Error", "Error", e);
            } finally {
                if (myDB != null)
                    myDB.close();
            }

        }
    });

    Button next = (Button) findViewById(R.id.buttonBack);
    next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent intent = new Intent();
            setResult(RESULT_OK, intent);
            finish();
        }

    });


}
}

Any suggestions ?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:29:24+00:00Added an answer on June 3, 2026 at 2:29 pm

    add android:clickable=”true” for TextView as:

    <TextView  
        android:id="@+id/multiAutoCompleteTextView1"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:clickable="true" 
        android:text="@string/hello"
        />
    

    EDIT:

    In viewall Activity :

    final TextView view2 = (TextView) findViewById(R.id.multiAutoCompleteTextView1);
    view2.setOnClickListener(listener);
     private OnClickListener listener = new OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (v.getId() == (R.id.multiAutoCompleteTextView1)) {
                view2.setText(inname.getText() + "!" + "Welcome to Android");
            } 
            else {
                Log.v(TAG, "....");
            }
        }
    
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in my data base that has three columns: Screen, Icon,
I have category model that has a tree structure. In my database I have
I have a rather large database that has alot of decimal columns in alot
I have a form created which an unbound datagridview that has three columns. Position,
I have three tables: computers, which has columns for id, serial number, make, model,
I have a database that has node & nodetype tables. Nodes table NodeID ParentNodeID
I have a SQL database that has a table with a field set to
I have inherited a database that has a lot of cursors in it, and
I have a database table that has a Unique Key constraint defined to avoid
I have a SQL database that has the following table: Table: PhoneRecords -------------- ID(identity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.