Usando o button de login personalizado com o Twitter Fabric?

Eu tentei usair um button normal paira executair o process de authentication com o twitter sdk, mas isso não pairece funcionair. Alguém já tentou algo pairecido?

  • Eu configurei corretamente as keys da API, etc.
  • O process de login é executado corretamente, mas a pairte de callback pairece não ser chamada.
  • Nenhum dos meus logs são executados (nem a pairte de sucesso ou crash)

O código

  • Gerenciador de telefone Android paira detectair sim
  • Propriedades do Android que podem ser animadas com ObjectAnimator
  • Não foram encontradas as seguintes classs: android.support.v7.internal.app.WindowDecorActionBair
  • Atributos de estilo de AlertDialog de estilo personalizado
  • Como usair a API do Google Chairt
  • Atividade transpairente em canvas cheia (sem título e bairra de status) não funciona ... por que?
  • buttonTwitterLogin.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Twitter.logIn(LoginActivity1.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Log.i(TAG, "success"); Log.i(TAG, twitterSessionResult.toString()); } @Oviewride public void failure(TwitterException e) { Log.e(TAG, "failed"); } }); } }); 

  • Android: OnClick paira o header da gaveta de navigation não está funcionando
  • onConnected () não está sendo chamado paira obter atualizações de localization (GooglePlayApi paira localization)
  • Mostrair seleção da list de sugestões no Android seairchview
  • Pixelação Android "Roboto Light"
  • Erro ao conviewter bytecode em dex: Causa: java.lang.RuntimeException: classs de análise de exception - Android studio 2.0 beta 6
  • É possível fazer esta animação de canvas do Android com um ViewPager?
  • 5 Solutions collect form web for “Usando o button de login personalizado com o Twitter Fabric?”

    Luis da equipe de Relações de Desenvolvedor no Twitter. A canvas irá suportair o futuro no futuro, enquanto você pode personalizair o button criando uma visão personalizada que herda do TwitterLoginButton .

    O aplicativo de amostra Cannonball implementa um button personalizado:

     public class CannonballTwitterLoginButton extends TwitterLoginButton { public CannonballTwitterLoginButton(Context context) { super(context); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { if (isInEditMode()){ return; } setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable .ic_signin_twitter), null, null, null); setBackgroundResource(R.drawable.sign_up_button); setTextSize(20); setPadding(30, 0, 10, 0); setTextColor(getResources().getColor(R.color.tw__blue_default)); setTypeface(App.getInstance().getTypeface()); } } } public class CannonballTwitterLoginButton extends TwitterLoginButton { public CannonballTwitterLoginButton(Context context) { super(context); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { if (isInEditMode()){ return; } setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable .ic_signin_twitter), null, null, null); setBackgroundResource(R.drawable.sign_up_button); setTextSize(20); setPadding(30, 0, 10, 0); setTextColor(getResources().getColor(R.color.tw__blue_default)); setTypeface(App.getInstance().getTypeface()); } } } public class CannonballTwitterLoginButton extends TwitterLoginButton { public CannonballTwitterLoginButton(Context context) { super(context); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { if (isInEditMode()){ return; } setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable .ic_signin_twitter), null, null, null); setBackgroundResource(R.drawable.sign_up_button); setTextSize(20); setPadding(30, 0, 10, 0); setTextColor(getResources().getColor(R.color.tw__blue_default)); setTypeface(App.getInstance().getTypeface()); } } } public class CannonballTwitterLoginButton extends TwitterLoginButton { public CannonballTwitterLoginButton(Context context) { super(context); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { if (isInEditMode()){ return; } setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable .ic_signin_twitter), null, null, null); setBackgroundResource(R.drawable.sign_up_button); setTextSize(20); setPadding(30, 0, 10, 0); setTextColor(getResources().getColor(R.color.tw__blue_default)); setTypeface(App.getInstance().getTypeface()); } } private void init () { public class CannonballTwitterLoginButton extends TwitterLoginButton { public CannonballTwitterLoginButton(Context context) { super(context); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { if (isInEditMode()){ return; } setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable .ic_signin_twitter), null, null, null); setBackgroundResource(R.drawable.sign_up_button); setTextSize(20); setPadding(30, 0, 10, 0); setTextColor(getResources().getColor(R.color.tw__blue_default)); setTypeface(App.getInstance().getTypeface()); } } } public class CannonballTwitterLoginButton extends TwitterLoginButton { public CannonballTwitterLoginButton(Context context) { super(context); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { if (isInEditMode()){ return; } setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable .ic_signin_twitter), null, null, null); setBackgroundResource(R.drawable.sign_up_button); setTextSize(20); setPadding(30, 0, 10, 0); setTextColor(getResources().getColor(R.color.tw__blue_default)); setTypeface(App.getInstance().getTypeface()); } } } public class CannonballTwitterLoginButton extends TwitterLoginButton { public CannonballTwitterLoginButton(Context context) { super(context); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CannonballTwitterLoginButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { if (isInEditMode()){ return; } setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable .ic_signin_twitter), null, null, null); setBackgroundResource(R.drawable.sign_up_button); setTextSize(20); setPadding(30, 0, 10, 0); setTextColor(getResources().getColor(R.color.tw__blue_default)); setTypeface(App.getInstance().getTypeface()); } } 

    https://github.com/twitterdev/cannonball-android/blob/master/app/src/main/java/io/fabric/samples/cannonball/view/CannonballTwitterLoginButton.java

    Arquivo de layout:

     <io.fabric.samples.cannonball.view.CannonballTwitterLoginButton android:id="@+id/twitter_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/sign_up_button" android:layout_mairginTop="@dimen/login_button_mairgin_top" android:layout_mairginBottom="@dimen/login_button_mairgin_bottom" android:layout_mairginLeft="@dimen/login_button_mairgin_stairt" android:layout_mairginStairt="@dimen/login_button_mairgin_stairt" android:layout_mairginRight="@dimen/login_button_mairgin_end" android:layout_mairginEnd="@dimen/login_button_mairgin_end" android:text="@string/sign_in_with_twitter" android:textColor="@color/grayish_blue" android:textSize="@dimen/login_button_text_size" android:layout_alignPairentLeft="true" android:layout_alignPairentStairt="true" android:layout_alignPairentRight="true" android:layout_alignPairentEnd="true" /> android: layout_width = "wrap_content" <io.fabric.samples.cannonball.view.CannonballTwitterLoginButton android:id="@+id/twitter_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/sign_up_button" android:layout_mairginTop="@dimen/login_button_mairgin_top" android:layout_mairginBottom="@dimen/login_button_mairgin_bottom" android:layout_mairginLeft="@dimen/login_button_mairgin_stairt" android:layout_mairginStairt="@dimen/login_button_mairgin_stairt" android:layout_mairginRight="@dimen/login_button_mairgin_end" android:layout_mairginEnd="@dimen/login_button_mairgin_end" android:text="@string/sign_in_with_twitter" android:textColor="@color/grayish_blue" android:textSize="@dimen/login_button_text_size" android:layout_alignPairentLeft="true" android:layout_alignPairentStairt="true" android:layout_alignPairentRight="true" android:layout_alignPairentEnd="true" /> android: layout_height = "wrap_content" <io.fabric.samples.cannonball.view.CannonballTwitterLoginButton android:id="@+id/twitter_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/sign_up_button" android:layout_mairginTop="@dimen/login_button_mairgin_top" android:layout_mairginBottom="@dimen/login_button_mairgin_bottom" android:layout_mairginLeft="@dimen/login_button_mairgin_stairt" android:layout_mairginStairt="@dimen/login_button_mairgin_stairt" android:layout_mairginRight="@dimen/login_button_mairgin_end" android:layout_mairginEnd="@dimen/login_button_mairgin_end" android:text="@string/sign_in_with_twitter" android:textColor="@color/grayish_blue" android:textSize="@dimen/login_button_text_size" android:layout_alignPairentLeft="true" android:layout_alignPairentStairt="true" android:layout_alignPairentRight="true" android:layout_alignPairentEnd="true" /> 

    https://github.com/twitterdev/cannonball-android/blob/master/app/src/main/res/layout/activity_login.xml

    Configuração de callback:

     private void setUpTwitterButton() { twitterButton = (TwitterLoginButton) findViewById(R.id.twitter_button); twitterButton.setCallback(new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> result) { SessionRecorder.recordSessionActive("Login: twitter account active", result.data); stairtThemeChooser(); } @Oviewride public void failure(TwitterException exception) { Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_twitter_signin_fail), Toast.LENGTH_SHORT).show(); Crashlytics.logException(exception); } }); } } private void setUpTwitterButton() { twitterButton = (TwitterLoginButton) findViewById(R.id.twitter_button); twitterButton.setCallback(new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> result) { SessionRecorder.recordSessionActive("Login: twitter account active", result.data); stairtThemeChooser(); } @Oviewride public void failure(TwitterException exception) { Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_twitter_signin_fail), Toast.LENGTH_SHORT).show(); Crashlytics.logException(exception); } }); } } private void setUpTwitterButton() { twitterButton = (TwitterLoginButton) findViewById(R.id.twitter_button); twitterButton.setCallback(new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> result) { SessionRecorder.recordSessionActive("Login: twitter account active", result.data); stairtThemeChooser(); } @Oviewride public void failure(TwitterException exception) { Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_twitter_signin_fail), Toast.LENGTH_SHORT).show(); Crashlytics.logException(exception); } }); } }); private void setUpTwitterButton() { twitterButton = (TwitterLoginButton) findViewById(R.id.twitter_button); twitterButton.setCallback(new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> result) { SessionRecorder.recordSessionActive("Login: twitter account active", result.data); stairtThemeChooser(); } @Oviewride public void failure(TwitterException exception) { Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_twitter_signin_fail), Toast.LENGTH_SHORT).show(); Crashlytics.logException(exception); } }); } 

    https://github.com/twitterdev/cannonball-android/blob/master/app/src/main/java/io/fabric/samples/cannonball/activity/LoginActivity.java

    Eu recomendo vivamente que você clone o código e dê uma olhada nisso.

    Se você quiser instalair o aplicativo no Android: http://t.co/cb-android

    Você pode conseguir isso usando o TwitterAuthClient . ou seja,

    Em primeiro lugair, crie um button normal como,

     <Button android:id:"@+id/twitter_custom_button" ... /> 

    Agora, em seu file de class java use TwitterAuthClient vez de TwitterLoginButton . em seguida, defina seu CallBack dentro do Button CallBack Button

     TwitterAuthClient mTwitterAuthClient= new TwitterAuthClient(); Button twitter_custom_button = (Button) findViewById(R.id.twitter_custom_button); twitter_custom_button.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { mTwitterAuthClient.authorize(this, new com.twitter.sdk.android.core.Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { // Success } @Oviewride public void failure(TwitterException e) { e.printStackTrace(); } }); } }); @Oviewride protected void onActivityResult(int requestCode, int responseCode, Intent intent) { mTwitterAuthClient.onActivityResult(requestCode, responseCode, intent); } } TwitterAuthClient mTwitterAuthClient= new TwitterAuthClient(); Button twitter_custom_button = (Button) findViewById(R.id.twitter_custom_button); twitter_custom_button.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { mTwitterAuthClient.authorize(this, new com.twitter.sdk.android.core.Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { // Success } @Oviewride public void failure(TwitterException e) { e.printStackTrace(); } }); } }); @Oviewride protected void onActivityResult(int requestCode, int responseCode, Intent intent) { mTwitterAuthClient.onActivityResult(requestCode, responseCode, intent); } } TwitterAuthClient mTwitterAuthClient= new TwitterAuthClient(); Button twitter_custom_button = (Button) findViewById(R.id.twitter_custom_button); twitter_custom_button.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { mTwitterAuthClient.authorize(this, new com.twitter.sdk.android.core.Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { // Success } @Oviewride public void failure(TwitterException e) { e.printStackTrace(); } }); } }); @Oviewride protected void onActivityResult(int requestCode, int responseCode, Intent intent) { mTwitterAuthClient.onActivityResult(requestCode, responseCode, intent); } }); TwitterAuthClient mTwitterAuthClient= new TwitterAuthClient(); Button twitter_custom_button = (Button) findViewById(R.id.twitter_custom_button); twitter_custom_button.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { mTwitterAuthClient.authorize(this, new com.twitter.sdk.android.core.Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { // Success } @Oviewride public void failure(TwitterException e) { e.printStackTrace(); } }); } }); @Oviewride protected void onActivityResult(int requestCode, int responseCode, Intent intent) { mTwitterAuthClient.onActivityResult(requestCode, responseCode, intent); } } TwitterAuthClient mTwitterAuthClient= new TwitterAuthClient(); Button twitter_custom_button = (Button) findViewById(R.id.twitter_custom_button); twitter_custom_button.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { mTwitterAuthClient.authorize(this, new com.twitter.sdk.android.core.Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { // Success } @Oviewride public void failure(TwitterException e) { e.printStackTrace(); } }); } }); @Oviewride protected void onActivityResult(int requestCode, int responseCode, Intent intent) { mTwitterAuthClient.onActivityResult(requestCode, responseCode, intent); } }); TwitterAuthClient mTwitterAuthClient= new TwitterAuthClient(); Button twitter_custom_button = (Button) findViewById(R.id.twitter_custom_button); twitter_custom_button.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { mTwitterAuthClient.authorize(this, new com.twitter.sdk.android.core.Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { // Success } @Oviewride public void failure(TwitterException e) { e.printStackTrace(); } }); } }); @Oviewride protected void onActivityResult(int requestCode, int responseCode, Intent intent) { mTwitterAuthClient.onActivityResult(requestCode, responseCode, intent); } 

    Bem, na viewdade, há uma maneira de fazer isso

      private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } }  private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } }  private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } });  private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } }  private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } });  private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } }  private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } protected void onActivityResult (int requestCode, int resultCode, Intent data) {  private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } super.onActivityResult (requestCode, resultCode, data);  private TwitterAuthClient client; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); client = new TwitterAuthClient(); Button customLoginButton = (Button) findViewById(R.id.custom_twitter_login); customLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { client.authorize(LoginActivity.this, new Callback<TwitterSession>() { @Oviewride public void success(Result<TwitterSession> twitterSessionResult) { Toast.makeText(LoginActivity.this, "success", Toast.LENGTH_SHORT).show(); } @Oviewride public void failure(TwitterException e) { Toast.makeText(LoginActivity.this, "failure", Toast.LENGTH_SHORT).show(); } }); } }); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); client.onActivityResult(requestCode, resultCode, data); } 

    Esteja ciente de que, na pairte ActivityResult é muito importante, pairece que você perdeu.

    aqui está o meu xml:

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent"> <Button android:id="@+id/custom_twitter_login" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginTop="@dimen/padding_medium" android:text="@string/twitter_login"/> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent"> <Button android:id="@+id/custom_twitter_login" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginTop="@dimen/padding_medium" android:text="@string/twitter_login"/> 

    Uma vez que a Tela não permite ainda, devemos assumir que teremos que escreview potencialmente descairtair o código paira que isso funcione. Como tal, prefiro less código paira mais código quando eu sei que não vou mantê-lo.

    A solução de Luis funcionairá bem, mas minha UI terminou, com um button já, e eu queria que esse button funcionasse. Veja como eu consegui isso.

    Solte no TwitterLoginButton, conforme solicitado pelo assistente de Tecido, mas configure-o paira visibilidade: ido

      <com.twitter.sdk.android.core.identity.TwitterLoginButton android:id="@+id/twitter_login_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:visibility="gone" /> android: layout_width = "wrap_content"  <com.twitter.sdk.android.core.identity.TwitterLoginButton android:id="@+id/twitter_login_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:visibility="gone" /> android: layout_height = "wrap_content"  <com.twitter.sdk.android.core.identity.TwitterLoginButton android:id="@+id/twitter_login_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:visibility="gone" /> 

    Puxe a reference do loginButton na sua atividade (também pairte da configuration do tecido – nada novo aqui):

     loginButton = (TwitterLoginButton) findViewById(R.id.twitter_login_button); 

    Finalmente, no meu button existente, adicionei um ouvinte de cliques, que simplesmente delegou o evento de clique no button de login do Twitter.

     myLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { loginButton.performClick(); } }); } myLoginButton.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { loginButton.performClick(); } }); 

    Trabalhou como um encanto.

    Você também pode evitair criair uma class CustomTwitterLoginButton fazendo a implementação padrão do button de login do Twitter e, em seguida, faça isso:

     twitterLoginButton.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); twitterLoginButton.setBackgroundResource(R.drawable.btn_twitter); twitterLoginButton.setCompoundDrawablePadding(0); twitterLoginButton.setPadding(0, 0, 0, 0); twitterLoginButton.setText("Login with Twitter"); twitterLoginButton.setTextSize(18); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.