2012-03-20 21 views
0

の一部を更新し、それがTextViewのボタンです:私は、ログイン画面の15%を持っている私の活動で活動

<TextView    
     android:id="@+id/registered_text" 
     android:color = "@color/white" 
     android:layout_width="wrap_content" 
     android:textSize="20dip" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dip" 
     ></TextView> 

     <Button 
     style="@style/myButton" 
     android:id="@+id/reg_button" 
     android:layout_width="wrap_content"  
     android:layout_alignParentRight="true"  
     android:layout_marginRight="10dip" 
     android:layout_height="wrap_content" 
    > 
    </Button>  

のTextView値とボタンのテキストとリスナーがユーザーに依存します登録されているかどうか:

loginDB login = new loginDB(context); 
    Cursor cursor = login.logData(new String[]{"userJoomla", "idUSER", "name","email"}); 

    if (cursor.moveToFirst()) { 
     userJoomla = cursor.getInt(0); 
     userID = cursor.getInt(1); 
     name = cursor.getString(2); 
     email = cursor.getString(3); 

     greeting.setText("Hola " + name); 
     loginLogout.setText("Desconectarme"); 

     loginLogout.setOnClickListener(logout); 
    } else { 
     name = "usuario móvil"; 
     greeting.setText(""); 
     loginLogout.setText("Identificarme"); 
     loginLogout.setOnClickListener(newLogin); 
    } 

    login.close(); 

ユーザーのログイン時またはログアウト時にどのように更新できますか?

ありがとうございました

+0

上のフラグメントを使用するCompatibility Libraryを使用しますか?画面全体を入れ替えたいですか? –

答えて

0

私は正確に何をしたいのか分かりません。ボタンのテキストを変更したり、完全な画面を置き換えたりするだけですか?

ボタンのキャプションを変更するのはかなり簡単です。あなたのonClickListenerで既に同じことをしてください:

loginLogout.setText("some new text"); 

画面全体を変更したい場合、ログイン/ログアウトには2つの方法で反応できます。 ログインが完了した後に新しいアクティビティを開始し、ログアウトが成功したときに現在のアクティビティを終了します

またはフラグメントを使用しています。

Fragmentsは、アクティビティのアクティビティと同じように「多かれ少なかれ」です。アクティビティーには複数のフラグメントが含まれることがあります。実行時にフラグメントを置換、追加、削除することができます。それはどのようにあなたの全体の画面またはその一部だけを交換することができますか?

はあなたがリフレッシュしたいものをデバイス<ハニカム

+0

私は断片について知りませんでしたが、彼らは私が探していたものです!ありがとう! – user1256477