1

私は、いくつかのデータをリストし、グラフを表示し、デフォルトのブラウザを起動してWebサイトにアクセスし(webviewを使用してアプリケーションではありません)、フォームを使用して電子メールを送信するsqlite Androidアプリケーションを作成しています。いくつかのフォームがあります。だから私が考えていたのは、いくつかのアクティビティとxmlレイアウトを使用する代わりに、すべてを1つのxmlレイアウトに入れ、ボタンをクリックするだけで、javascriptで行われるようにコンポーネントを表示および非表示にすることです。これらは今のところ私のコンポーネントです...

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
     android:layout_height="fill_parent">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="432dp"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="32dp"
        android:text="ENTER COMPANY NAME " />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:ems="10">

        <requestFocus />
    </EditText>

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="17dp" 
        android:entries="@array/country_arrays"
        android:prompt="@string/country_prompt"
        />

    <Spinner
        android:id="@+id/spinner2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/spinner1"
        android:layout_below="@+id/spinner1" 
        android:entries="@array/limit_arrays"
        android:prompt="@string/limit_prompt"
        />

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/spinner2"
        android:layout_centerHorizontal="true"
        android:text="Hide" />

    <Button
        android:id="@+id/button2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/button1"
        android:layout_centerHorizontal="true"
        android:text="Show" />

</RelativeLayout>
</ScrollView>

次に、たとえばを使用してコンポーネントを表示または非表示にします

spinner1.setVisibility(View.VISIBLE); 
spinner1.setVisibility(View.GONE); 

これは正常に動作しているようですが、xml 画面のスペースが少なくなっています。下部にコンポーネントを追加してビューを下にスクロールするにはどうすればよいですか?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
     android:layout_height="fill_parent">

私のxmlレイアウトの上に。そして、これはメニュー構成にとって良い考えですか?

4

0 に答える 0