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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:48:31+00:00 2026-06-17T12:48:31+00:00

I just started programming a little password manager but every time I run it

  • 0

I just started programming a little password manager but every time I run it in the emulator, it crashes and I get the following error:

android.widget.TextView cannot be cast to android.widget.EditText

Is everyone seeing the mistake?

MainActivity.java:

package de.lennartschoch.passwordmanager;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

Button login;
EditText masterpassfield;
String masterpass;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    login = (Button) findViewById(R.id.login);
    masterpassfield = (EditText) findViewById(R.id.masterpass);
    masterpass = "password";
    login.setOnClickListener(new OnClickListener() {


        @Override
        public void onClick(View view) {

            if(masterpassfield.getText().toString() == masterpass) {

                Intent success = new Intent(view.getContext(), Passwords.class);
                startActivityForResult(success, 0);

            }

        }});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}

activity_main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<EditText
    android:id="@+id/masterpass"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_alignRight="@+id/textView1"
    android:layout_centerVertical="true"
    android:ems="10"
    android:inputType="textPassword" />

<Button
    android:id="@+id/login"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/masterpass"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:text="@string/login" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/masterpass"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="20dp"
    android:text="@string/masterpasstext"
    android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>
  • 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-17T12:48:32+00:00Added an answer on June 17, 2026 at 12:48 pm

    Project -> Clean seems to be the only solution to me.

    Trying cleaning your project a few times and then build it.

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

Sidebar

Related Questions

I've just started programming in Qt framework. Following is a very simple program: #include
I started programming just few month ago so I am a pure beginner but
i have just started programming for android and i have a little question i
sorry for this newb question, i just started programming with php I'm following Yahoo
I just started programming and tried to write something but (of course) it failed.
I just started programming in Java, and I need to get a simple application
I've just started programming and I've got this far but I've been struggling with
I've just started programming with Java, so might appear as silly question, but I
I've just started programming a online highscore for the first time, and it's for
I just started programming in Basic4android. I have created 2 layouts. splash and search

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.