2013-10-09 36 views
0

我正在开发一个android应用程序。我需要它,以便当用户创建一个帐户时,应用程序从新成员类获取用户输入,并在另一个类中创建输出。例如,用户输入他们的姓名。在应用程序主屏幕上,这是一个完全不同的类,他们能够看到“Hello%name%!今天你想做什么?”在这里,我有我的新用户类。一个类的输入和另一个的输出?

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.EditText; 

public class NewScreen extends Activity { 


EditText textEdit4; 
EditText textEdit5; 
EditText editText3; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.newscreen); 

    textEdit4 = (EditText) findViewById(R.id.textEdit4); 

    textEdit5 = (EditText) findViewById(R.id.textEdit5); 

    editText3 = (EditText) findViewById(R.id.editText3); 




    Button btn_submit = (Button) findViewById(R.id.btn_submit); 
    btn_submit.setOnClickListener(new OnClickListener() { 
     public void onClick(View v) { 
      Intent intent = new Intent(); 
      intent.setClassName("net.contents.fbla", "net.contents.fbla.NewScreen2"); 
      startActivity(intent); 
     } 
    }); 


} 
    } 
    ` 

和我的XML用于表示类

<TextView 
    android:id="@+id/textView4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/email_string" /> 

<EditText 
    android:id="@+id/textEdit4" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:ems="10" 
    android:inputType="textEmailAddress" > 

    <requestFocus /> 
</EditText> 

<TextView 
    android:id="@+id/textView5" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/pass_string" /> 

<EditText 
    android:id="@+id/textEdit5" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:ems="10" 
    android:inputType="textPassword" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/name" /> 

<EditText 
    android:id="@+id/editText3" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:ems="10" 
    android:inputType="textPersonName" /> 

<Button 
    android:id="@+id/btn_submit" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/btn_submit" /> 

<ProgressBar 
    android:id="@+id/progressBar1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

任何帮助都行!谢谢-Jeremy

+0

如果你想要的是通过活动之间的对象,检查了这一点: http://stackoverflow.com/questions/2736389/how-to-pass-object-from-one-activity-to-another-in-android – luanjot

+0

或者简单地说,http://stackoverflow.com/a/5265952/2345913 – CRUSADER

+0

你可以使用意图在不同的数据之间传递数据活动 –

回答

0

你真的需要一个包中的所有类。 Android - Package Name convention在eclipse中的src文件夹中,你可能已经在默认包中有你的类,这是不好的。按照惯例在src下创建一个新的包,你的包的名称是你网站的反向链接,因为这肯定是唯一的,只能使用period而不是slash.example com.stackoverflow。现在在您的源代码中添加包com.stackoverflow;在你java.only的第一行不使用计算器的原因这是一个例子

相关问题