setContentView(R.layout.form_layout (the new layout is form_layout)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="5">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Please submit your details"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="46dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Name"
android:ems="10"
android:id="@+id/editText"
android:layout_marginTop="46dp"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:hint="Name" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText2"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="46dp"
android:hint="Email" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="@+id/editText3"
android:layout_below="@+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="46dp"
android:hint="Password" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="@+id/editText4"
android:layout_below="@+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="46dp"
android:hint="Confirm Password" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="5">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"
android:src="@mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Terms & Conditions"
android:id="@+id/textView2"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="A Terms and Conditions can be used for both your "
android:id="@+id/textView3"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I agree"
android:id="@+id/checkBox"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="38dp"
android:layout_marginStart="38dp"
android:layout_marginBottom="38dp"
android:checked="false"
android:layout_marginRight="46dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Can't wait!Sign me up!"
android:id="@+id/button"
android:layout_alignTop="@+id/checkBox"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="85dp"
android:layout_marginEnd="75dp" />
</RelativeLayout>
</LinearLayout>
MainFormular.java
package com.example.melisa.myformular;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
public class MainFormular extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.form_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById (R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main_formular, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
在Android.app.activity.performCreate(activity_main_formular
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main_formular" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
洛克卡特
请删除此代码并尝试运行您的应用程序......
在您的布局中,FloatingActionButton视图不在那里,您正试图绑定并在该视图上创建click事件。
FloatingActionButton fab = (FloatingActionButton) findViewById (R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
而这也......
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main_formular, menu);
return true;
}
问题内容: 当我右键单击我的Android项目并选择时。模拟器启动,所做的更改确实反映出来。 但是当我执行以下以下命令时,它不会反映出来。 而且,如果没有打开模拟器,则deploy and emulator-start命令将失败。 。 这是我的android-maven-plugin-emulator-start.vbs文件。 这是我的POM.XML 问题答案: 跑之前。Maven插件无法部署到不
我必须改用eclipse吗? IDE显示以下消息:
问题内容: Android Studio模拟器无法在Kali Linux中启动。我得到的错误是: 17/12/25上午3:01 Gradle同步开始 凌晨3:01开始项目设置 3:01 AM Gradle同步以1s 333ms完成(从缓存状态开始) 上午3:02 *守护程序未运行;现在从tcp:5037开始 上午3:02模拟器:libGL错误:无法加载驱动程序:i965_dri.so 上午3:02
我一直在做一个android项目,我在我的iMac上使用android studio[软件OS X 10.9.5,图形英特尔高清图形5000 1024 MB,处理器1.4GHz英特尔酷睿i5]。 我可以在谷歌上找到很多类似的解决方案&所以,但我不能在Mac上使用这些解决方案??? 我遵循了这里给出的所有步骤,但运气不好,仍然无法启动模拟器。我想这和mac OS有关。 有人能告诉我在MAC上怎么做吗
我尝试在Ubuntu14.04的android Studio中启动模拟器中的应用程序,结果显示以下错误。 正在进行渐变生成时显示错误: /home/next/nte/machinesetup/android-sdk-linux/tools/emulator-netdelay none-netspeed full-avd Nexus_5X_API_24无法启动“/home/next/nte/mach
我认为这是项目结构中的SDK引用的问题,但是当我单击run并选择Launch Emulator时,什么也不会出现。