2012-05-04 6 views
1

エラーが発生しました。ログインが解決されないか、passwdとipのフィールドエラーではありません。 アンドロイドプログラムを実行中にeclipseでこのエラーが発生します。は解決できないか、またはeclipseのアンドロイドでフィールドエラーではありません

public void onClick(View v) { 
    if (v == this.viewcam) 
     { 
     Log.i("login", this.login.getText().toString()); 
     Log.i("Passwd", this.passwd.getText().toString()); 
     Intent localIntent1 = new Intent(v.getContext(), MjpegSample.class); 
     Log.i("My ip", this.editTextIp.getText().toString()); 
     localIntent1.putExtra("ip", "http://" + this.editTextIp.getText().toString() + "/"); 
     localIntent1.putExtra("user", this.login.getText().toString()); 
     localIntent1.putExtra("passwd", this.passwd.getText().toString()); 
     startActivityForResult(localIntent1, 1000); 
     } 
    } 
}); 

それはOnClickListenerのインスタンスを指すように、次の私はこのコードはOnClickListenerであると仮定

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 
    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="IP CAM VIEWER" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     /> 
</LinearLayout> 
<TableLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
    <TableRow 
     android:id="@+id/tableRow1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 
     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Username : " 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 
     <EditText 
      android:id="@+id/username" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:ems="10" > 
      <requestFocus /> 
     </EditText> 
    </TableRow> 
    <TableRow 
     android:id="@+id/tableRow2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 
     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Password : " 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 
     <EditText 
      android:id="@+id/password" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:inputType="textPassword" /> 
    </TableRow> 
    <TableRow 
     android:id="@+id/tableRow3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 
     <TextView 
      android:id="@+id/textView4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="IP : " 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 
     <EditText 
      android:id="@+id/ip" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:ems="10" /> 
</TableLayout> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.62" > 
    <Button 
     android:id="@+id/viewcam" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginRight="96dp" 
     android:layout_marginTop="16dp" 
     android:text="View cam" /> 
</RelativeLayout> 
</LinearLayout> 

答えて

1

上記に対応するmain.xmlファイルであり、この場合には、thisキーワードを削除しますなく、アクティビティインスタンス:

public void onClick(View v) { 
    if (v == viewcam) 
     { 
     Log.i("login", login.getText().toString()); 
     Log.i("Passwd", passwd.getText().toString()); 
     Intent localIntent1 = new Intent(v.getContext(), MjpegSample.class); 
     Log.i("My ip", editTextIp.getText().toString()); 
     localIntent1.putExtra("ip", "http://" + editTextIp.getText().toString() + "/"); 
     localIntent1.putExtra("user", login.getText().toString()); 
     localIntent1.putExtra("passwd", passwd.getText().toString()); 
     startActivityForResult(localIntent1, 1000); 
     } 
    } 

別のオプションは、たとえば、thisを「完全に修飾する」ことです。

Log.i("login", TheActivity.this.login.getText().toString()); 
+0

お返事ありがとうございます。私は今それを試してみる – radish

関連する問題