2013-08-22 133 views
0

我可以創建彈出窗口作爲註冊或登錄窗口嗎?創建彈出窗口作爲註冊aur登錄窗口

我必須創建一個屏幕覆蓋另一個像我單擊註冊按鈕時它應該打開爲彈出。可能嗎?

或告訴我任何其他技術,通過它我可以創建覆蓋前一個屏幕的另一個屏幕。 基本上我創建了一個屏幕上有2個按鈕,一個是登錄和signup.i必須創建類似於當我點擊登錄按鈕時彈出另一個屏幕,我可以填寫的細節,並在數據庫中提交。

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.activity_main); 
    usernamelogin = (EditText) findViewById(R.id.editTextUserNameToLogin); 
    passwordlogin = (EditText) findViewById(R.id.editTextPasswordToLogin); 
    login = (Button) findViewById(R.id.login_mainactivity); 

    login.setOnClickListener(new OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      initiatePopupWindow(); 
     } 
    }); 
} 
private PopupWindow pwindo; 

private void initiatePopupWindow() { 
    try{ 

    // We need to get the instance of the LayoutInflater 
    LayoutInflater inflater = (LayoutInflater) MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View layout = inflater.inflate(R.layout.activity_login,(ViewGroup) findViewById(R.id.popup_element)); 
    pwindo = new PopupWindow(layout, 300, 370, true); 
    pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0); 
    btnlogin = (Button) layout.findViewById(R.id.Login_loginscreen); 

    btnlogin.setOnClickListener(login_button_click_listener); 


    } 
     catch (Exception e) { 
      e.printStackTrace(); 
      } 


    } 
private OnClickListener login_button_click_listener = new OnClickListener() {  
public void onClick(View arg0) { 
      // Retrieve the text entered from the EditText 
      usernamelgn = usernamelogin.getText().toString(); 
      passwordlgn = passwordlogin.getText().toString(); 

      // Send data to Parse.com for verification 
      ParseUser.logInInBackground(usernamelgn, passwordlgn,new LogInCallback() { 
       public void done(ParseUser user, ParseException e) { 
        if (user != null) { 
         // If user exist and authenticated, send 
         // user to category.class 
         Intent intent = new Intent(
           MainActivity.this, Category.class); 
         startActivity(intent); 
         Toast.makeText(getApplicationContext(), 
           "Successfully Logged in", 
           Toast.LENGTH_LONG).show(); 
         finish(); 
        } else { 
         Toast.makeText(
           getApplicationContext(), 
           "No such user exist, please signup", 
           Toast.LENGTH_LONG).show(); 
        } 
       } 

      }); 

     } 
    }; 

回答

0

你可以按照this關於`DialogFragments'的教程。