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 8854881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:59:12+00:00 2026-06-14T13:59:12+00:00

All right, so I’ve been a few hours on this, and can’t get it

  • 0

All right, so I’ve been a few hours on this, and can’t get it to work.
Basically, I wanna call an intent from a clickable listview. I’m displaying car models and it’s code on a list, when you click, you’re supposed to be taken to another screen to edit the car’s properties, however, I’m beggining to think it’s impossible

listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, arrayListCarros);  
    mainListView.setAdapter( listAdapter );      
    db.close();

    mainListView.setClickable(true);
    mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {

            Intent i = new Intent(listagemcarro.this,com.example.trabalhosql.edicao.class);  
            startActivity(i);



      }
    });

The rest of the code:

    public class listagemcarro extends Activity {
Button buttonCadastro;
Button buttonListagem;
Button buttonBusca;
Button button1;

Intent itListagem = new Intent();
Intent itCadastro = new Intent();
Intent itBusca = new Intent();
//Intent itEdicao = new Intent();
Intent itEdicao2 = new Intent();

String id="";   

public SQLiteDatabase db;
public String BANCO = "banco.db";
public String TABELA = "carro";
int posicao=123123;

private ListView mainListView ;  
private ArrayAdapter<String> listAdapter ;  

public void toast(int position){
    Context context = getApplicationContext();
    Toast toast = Toast.makeText(context, position, Toast.LENGTH_SHORT);
    toast.show(); 

}
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listagemcarro);

    Intent itRecebeParametros = getIntent();
    if(itRecebeParametros != null){
        id = itRecebeParametros.getStringExtra("id");
    }


    db = openOrCreateDatabase(BANCO, Context.MODE_PRIVATE, null);
    Cursor linhas = db.query(TABELA, new String[] {"ID_PESSOA, MODELO"},"id_pessoa = '"+id+"'", null, null, null, null);

    mainListView = (ListView) findViewById( R.id.mainListView );  

    ArrayList <String>arrayListCarros = new ArrayList<String> ();  

    if(linhas.moveToFirst()){ 
        do{
            arrayListCarros.add(linhas.getString(0) +" " + linhas.getString(1));
        }
    while(linhas.moveToNext()); 
    }

    listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, arrayListCarros);  
    mainListView.setAdapter( listAdapter );      
    db.close();

    mainListView.setClickable(true);
    mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {

            Intent i = new Intent(listagemcarro.this,com.example.trabalhosql.edicao.class);  
            startActivity(i);



      }
    });

}

error

11-19 23:18:09.136: W/dalvikvm(1784): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
11-19 23:18:09.136: E/AndroidRuntime(1784): Uncaught handler: thread main exiting due to uncaught exception
11-19 23:18:09.147: E/AndroidRuntime(1784): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.trabalhosql/com.example.trabalhosql.edicao}: java.lang.NullPointerException
11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)

11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.os.Looper.loop(Looper.java:123)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.app.ActivityThread.main(ActivityThread.java:4363)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at java.lang.reflect.Method.invokeNative(Native Method)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at java.lang.reflect.Method.invoke(Method.java:521)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at dalvik.system.NativeStart.main(Native Method)
11-19 23:18:09.147: E/AndroidRuntime(1784): Caused by: java.lang.NullPointerException
11-19 23:18:09.147: E/AndroidRuntime(1784):     at com.example.trabalhosql.edicao.onCreate(edicao.java:42)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-19 23:18:09.147: E/AndroidRuntime(1784):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
11-19 23:18:09.147: E/AndroidRuntime(1784):     ... 11 more

edicao.class

package com.example.trabalhosql;

import java.util.ArrayList;

import android.os.Bundle;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class edicao extends Activity {

String id="";   
String modeloCarro = "";
TextView textViewCarroEscolhido;

public SQLiteDatabase db;
public String BANCO = "banco.db";
public String TABELA = "carro";

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listagemcarro);

    Intent itRecebeParametros = getIntent();
    if(itRecebeParametros != null){
        id = itRecebeParametros.getStringExtra("id");
        modeloCarro = itRecebeParametros.getStringExtra("modeloCarro");
    }

    textViewCarroEscolhido = (TextView) findViewById(R.id.textViewCarroEscolhido);
    textViewCarroEscolhido.setText(modeloCarro);
}

}

  • 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-14T13:59:13+00:00Added an answer on June 14, 2026 at 1:59 pm

    EDIT

    I’m guessing that this part of the edicao class is incorrect:

    setContentView(R.layout.listagemcarro);
    

    That itself might not have thrown the error, but trying to finding views (like your textView) in it that don’t exist would.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All right so I've been looking all over the net and I can't seem
All right, do not get angry now, I know there are several questions about
All right, I'll try to explain my problem as clearly as I can. I
All right so I tried using the button set. So fair, I have been
All right, this one is going to sound very weird and I don't know
All right this is kind of embarrassing, but I am not sure what is
I'm quite new to nhibernate, I was doing all right until I face this
I need twoway binding configClass.RaMsize to numericUpDown. BindField(this.upDownRamSize, Value, configClass, RaMsize);//all right this.upDownRamSize.Value =
All right, this must be an absolutely easy question, and I apologize for that.
All right, so previously I asked... SOAP Prototype AJAX SOAPAction Header Question (can't hyperlink

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.