UI的Andr​​oid Studio错误 [英] UI android studio error

查看:546
本文介绍了UI的Andr​​oid Studio错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在Android Studio中应用程序登录
当我打开应用程序,我不能键入用户名和密码字段anythings(edittext-登录活动)..它不是剂量表明,有一个EditText!
我的清单code以下

i am working on login app in android studio when i open the app I can't type anythings in the username and password field (edittext- login activity).. it dose not show that there is an edittext!! My Manifest code below

 <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".Login"
        android:label="@string/title_activity_login"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>


    <activity android:name=".SingUp"></activity>

</application>

我的logcat低于

03-15 07:42:08.206 2220-2220/com.example.dp_7_kholood.taskone I/art: Not late-enabling -Xcheck:jni (already on)
03-15 07:42:08.253 2220-2220/com.example.dp_7_kholood.taskone W/System: ClassLoader referenced unknown path: /data/app/com.example.dp_7_kholood.taskone-1/lib/x86
03-15 07:42:08.323 2220-2235/com.example.dp_7_kholood.taskone D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
03-15 07:42:08.460 2220-2235/com.example.dp_7_kholood.taskone I/OpenGLRenderer: Initialized EGL, version 1.4
03-15 07:42:08.491 2220-2235/com.example.dp_7_kholood.taskone W/EGL_emulation: eglSurfaceAttrib not implemented
03-15 07:42:08.492 2220-2235/com.example.dp_7_kholood.taskone W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabfab2e0, error=EGL_SUCCESS
03-15 07:42:11.887 2220-2235/com.example.dp_7_kholood.taskone W/EGL_emulation: eglSurfaceAttrib not implemented
03-15 07:42:11.887 2220-2235/com.example.dp_7_kholood.taskone W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabfabdc0, error=EGL_SUCCESS
03-15 07:42:11.967 2220-2235/com.example.dp_7_kholood.taskone W/EGL_emulation: eglSurfaceAttrib not implemented
03-15 07:42:11.967 2220-2235/com.example.dp_7_kholood.taskone W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xad809160, error=EGL_SUCCESS
03-15 07:42:12.053 2220-2235/com.example.dp_7_kholood.taskone E/Surface: getSlotFromBufferLocked: unknown buffer: 0xab850b20
03-15 07:42:13.847 2220-2235/com.example.dp_7_kholood.taskone E/Surface: getSlotFromBufferLocked: unknown buffer: 0xab850c70
03-15 07:42:15.311 2220-2235/com.example.dp_7_kholood.taskone W/EGL_emulation: eglSurfaceAttrib not implemented
03-15 07:42:15.311 2220-2235/com.example.dp_7_kholood.taskone W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabfab400, error=EGL_SUCCESS
03-15 07:42:15.400 2220-2235/com.example.dp_7_kholood.taskone E/Surface: getSlotFromBufferLocked: unknown buffer: 0xab8525d0
a

我的登录活动XML

   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Username"
    android:id="@+id/TVusername"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/Tfusername"
    android:layout_below="@+id/TVusername"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Password"
    android:id="@+id/textView2"
    android:layout_below="@+id/Tfusername"
    android:layout_alignRight="@+id/TVusername"
    android:layout_alignEnd="@+id/TVusername"
    android:layout_marginTop="24dp" />

<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:ems="10"
    android:id="@+id/Tfpassword"
    android:layout_below="@+id/textView2"
    android:layout_alignLeft="@+id/textView2"
    android:layout_alignStart="@+id/textView2"
    android:layout_alignRight="@+id/Tfusername"
    android:layout_alignEnd="@+id/Tfusername" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Login"
    android:id="@+id/Blogin"
    android:onClick="onButtonClick"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Sign Up"
    android:id="@+id/BtnSingup"
    android:layout_below="@+id/Blogin"
    android:layout_alignLeft="@+id/Blogin"
    android:layout_alignStart="@+id/Blogin"
    android:onClick="onButtonClick" />

我的java code像下面

public class Login extends AppCompatActivity {

DatabaseHelper helper=new DatabaseHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

}

public void onButtonClick(View v){


    if (v.getId() == R.id.Blogin);
    {
        EditText a = (EditText)findViewById(R.id.Tfusername);
        String str= a.getText().toString();
        EditText b = (EditText)findViewById(R.id.Tfpass);
        String pass= b.getText().toString();
        String password= helper.searchPass(str);

        if(pass.equals(password)){

        Intent i= new Intent(Login.this, SingUp.class);
        i.putExtra("Username",str);
        startActivity(i);

    }

        else{
            Toast t=Toast.makeText(Login.this, "Username and Paasword not match!", Toast.LENGTH_SHORT);
            t.show();
        }}
    if(v.getId()==R.id.BtnSingup){

         Intent i= new Intent(Login.this, SingUp.class);
         startActivity(i);
    }
}

}

推荐答案

正在搞乱的基础。

问题是你已经删除了父视图。只需做一件事:

The problem is you have removed the parent view. Just do one thing:

创建一个新的活动。打开 content_activity.xml (新活动)做不会从这个XML文件中删除所有code。您将获得使用默认父视图。现在复制所有的textviews和editTexts,并添加为孩子的父视图。像这样的:

Create a new activity. Open the content_activity.xml (of new activity) do NOT remove any code from this xml file. You will be provided with the default parent view. Now copy all of your textviews and editTexts and add as a child to the parent view. Like this:

<RelativeLauout>
   <TextView/>
   <EditText/>
</RelativeLayout>

下面的 RelativeLayout的是父视图。

这将帮助你理解这个概念。

This will help you understand the concept.

这篇关于UI的Andr​​oid Studio错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆