2015-12-30 65 views
-3

这是我写的代码在我的应用程序中创建按钮。按钮没有在我的Android应用程序中创建

该代码是好的,但它也没有得到创建。

<Button 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:onClick="dosomething" 
      android:text="mybutton" /> 
+0

其中是您的代码 – Ranjit

+0

发布完整的XML代码 – Pankaj

回答

0

使用此。

<LinearLayout 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"> 


<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="New Button" 
    android:id="@+id/button" /> 
</LinearLayout> 
+0

该代码创建按钮的上面的代码如下: - <?XML版本=“1.0”编码=“UTF-8”> <机器人.support.design.widget.CoordinatorLayout xmlns:android =“http://schemas.android.com/apk/res/android” xmlns:app =“http://schemas.android.com/apk/res-auto “ 的xmlns:工具=” http://schemas.android.com/tools “ 的android:layout_width = ”match_parent“ 机器人:layout_height = ”match_parent“ 机器人:方向= ”横向“ 机器人:fitsSystemWindows =” 真“ 工具: context =“com.example.asad.button.MainActivity”> wht – asad

+0

使用我的代码..是不是在工作? –

+0

我已经使用了CoordinatorLayout。 – asad

相关问题