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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:53:35+00:00 2026-05-29T03:53:35+00:00

I am trying to create 5 buttons in my main activity and am trying

  • 0

I am trying to create 5 buttons in my main activity and am trying to put new activities in them.

In the fifth button, I am having a problem with listView.

In the below code, am I missing anything required for the listView(View v) method to work properly?

Here is my code:

listActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</ListView>
   
</LinearLayout>

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="newActivity"
    android:text="Yeni Aktivite" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="toast"
    android:text="Toast" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="web"
    android:text="Web" />

<Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="preferences"
    android:text="Preferences" />

<Button
    android:id="@+id/button5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="listVieww"
    android:text="ListView" />

  </LinearLayout>

Main activity

package com.uygulamalar.odev;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class OdevKarmaActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        
    }

    public void newActivity(View v) {
        Intent intent = new Intent(getApplicationContext(), NewActivity.class);
        startActivity(intent);
    }

    public void toast(View v) {
        Toast toast=Toast.makeText(getApplicationContext(), "vazzupp", 9999);
        toast.show();
    }

    public void listVieww(View v) {
        ListView listView1;
        String jedigiller[] = {"pelin","figen","aylin","gizem"};
    
        listView1=(ListView) findViewById(R.id.listView1);
        listView1.setAdapter(new
                ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , jedigiller));
    }
}

When run, the code forces the Android emulator to close.

I am suspecting that the issue is related to the listView(View v) method, did I miss anything when using it?

  • 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-05-29T03:53:35+00:00Added an answer on May 29, 2026 at 3:53 am

    You are attempting to reference a ListView found in listActivity.xml, while you have set your content view to main.xml.

    Either copy the ListView over to main.xml, or start a new Activity in listVieww() that displays the list, and uses setContentView(R.layout.listActivity);

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

Sidebar

Related Questions

I am trying to create a BUTTON over BITMAP or OVERLAYING buttons on the
I'm trying to dynamically create buttons at runtime with PyQT4.7 However, this being my
I'm trying to create css buttons by using the following html markup: <a href=access.php
Hey, I'm trying to create Like Buttons for Facebook Photos, but can't figure out
I am trying to create a UIAlertView with three buttons (which will be stacked).
I am trying to create a form with many groups containing many radio buttons.
I'm trying to create a top panel menu that contains 5 buttons. I configured
I am trying to create an interface, where two or more buttons will be
I am trying to create a rich text editor. I have created some buttons
I'm trying to decide whether I should create a simple StackPanel with Buttons on

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.