2017-03-05 1 views
1

Javaコードを解釈しようとしていますが、ScrollViewクラスをインポートせずにScrollViewオブジェクトを作成する方法がわかりません。なぜこれが可能なのか誰も説明できますか? XMLファイルにScrollViewタグが表示されません。android ScrollViewクラスをインポートせずにscrollviewオブジェクトを作成することはできますか?

MainActivity.Java ScrollViewを含め、android.widgetの下にあるすべてのものを輸入し

import android.os.Bundle; 
import android.app.Activity; 
import android.graphics.Color; 
import android.view.Gravity; 
import android.view.View; 
import android.widget.*; 

public class Form extends Activity { 

    ScrollView sv; 
    TableLayout myLayout; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     sv = new ScrollView(this); 
     myLayout = new TableLayout (this); 
     drawScreen(); 
    } 
    //more code... 
    ///.... 

activity_main.xml

<RelativeLayout 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" 
    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/text1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/textView" 
    /> 

</RelativeLayout> 

答えて

1
import android.widget.*; 

:これは、次のコードです。

+0

だからアスタリスクは、すべてのアンドロイドウィジェットをインポートするのですか?賢い – programmingblues

関連する問題