Java 我想用一个对话框显示两个数字选择器
您好,这正是我一直在寻找添加到我的应用程序,但我得到一个错误McContext是未定义的-我如何修复这个?还有一种方法可以通过xml布局实现这一点吗?提前谢谢你,我是android新手,请点击此链接。。。 布局:Java 我想用一个对话框显示两个数字选择器,java,android,Java,Android,您好,这正是我一直在寻找添加到我的应用程序,但我得到一个错误McContext是未定义的-我如何修复这个?还有一种方法可以通过xml布局实现这一点吗?提前谢谢你,我是android新手,请点击此链接。。。 布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_wid
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="255dp"
android:layout_height="match_parent"
android:layout_gravity="top|center"
android:background="#50CCCCCC"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text=" "
android:textAppearance="?android:attr/textAppearanceSmall" />
<NumberPicker
android:id="@+id/np"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/expmin"
android:layout_toLeftOf="@+id/textView3" />
<TextView
android:id="@+id/expmin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/np"
android:layout_below="@+id/textView3"
android:text="Exp.Min"
android:textColor="#3276b1"
android:textStyle="bold|italic"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/numberPicker1"
android:layout_below="@+id/textView3"
android:layout_toRightOf="@+id/textView3"
android:text="Exp.Max"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#3276b1"
android:textStyle="bold|italic" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/np"
android:layout_toRightOf="@+id/np"
android:background="@drawable/button_selector"
android:text=" OK "
android:textColor="#3276b1" />
<NumberPicker
android:id="@+id/numberPicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button"
android:layout_toRightOf="@+id/button"
android:gravity="right" />
</RelativeLayout>
<!-- <Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/button_selector"
android:text=" OK "
android:textColor="#3276b1" /> -->
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textAppearance="?android:attr/textAppearanceMedium" />
请添加一些代码和LogCat输出,以便我们可以分析您的ErrorMcContext是一个定义为应用程序上下文的变量。您需要在代码中定义是否有方法使用xml布局来实现这一点?不可以。您只使用Java代码定义上下文。链接上使用的代码-我将根据自己的需要进行调整,只是想先删除错误:。不幸的是,我是stackoverflow新手,无法发布我的代码:您的xml违反了xml规则。只有一个顶级元素。您好,谢谢:-不幸的是,我在java中遇到错误,无法解决Symbol我在很多事情上都遇到了这个问题,包括-requestWindowFeature-setContentView-length-setMaxValue-SetMinValue这与我的主要活动扩展有什么关系?对不起,我是Android的新手,你能不能把你为numberpic实现的所有代码片段都贴出来。。。