I have seen questions/solutions here for the keyboard not showing up, but none relating to my specific issue. When you click an EditText, the keyboard shows up fine. But, when I animate the EditText first, then when you click the EditText the keyboard will NOT show up.
Any ideas why this could be happening?
In my Activity I first animate my logo, and after it's done animating I create a fade-in animation for the EditTexts. After they finish the animation, I try and click any of them but the keyboard will not show up.
Here is my onCreate method in my Activity:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); //Remove title bar
setContentView(R.layout.login);
final EditText emailField = (EditText) findViewById(R.id.emailField);
final EditText passwordField = (EditText) findViewById(R.id.passwordField);
final TextView logInText = (TextView) findViewById(R.id.logInText);
final Button signupButton = (Button) findViewById(R.id.signupButton);
final Button loginButton = (Button) findViewById(R.id.loginButton);
//animation of logo
ImageView img_animation = (ImageView) findViewById(R.id.encoreLogo);
TranslateAnimation animation = new TranslateAnimation(0.0f, 00f,
0.0f, -400.0f);
animation.setDuration(4000);
animation.setFillAfter(true);
animation.setStartOffset(2000);
img_animation.startAnimation(animation);
animation.setAnimationListener(new AnimationListener() {
#Override
public void onAnimationEnd(Animation animation) {
Animation animFadeIn = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
animFadeIn.setDuration(2000);
animFadeIn.setFillAfter(true);
emailField.setAnimation(animFadeIn);
passwordField.setAnimation(animFadeIn);
logInText.setAnimation(animFadeIn);
loginButton.setAnimation(animFadeIn);
signupButton.setAnimation(animFadeIn);
}
#Override
public void onAnimationRepeat(Animation animation) {}
#Override
public void onAnimationStart(Animation animation) {}
});
signupButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this, SignUpActivity.class);
MainActivity.this.startActivity(myIntent);
}
});
}
and here is my corresponding login.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/backroundImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:cropToPadding="false"
android:scaleType="centerCrop"
android:src="#drawable/crowdblur1" />
<ImageView
android:id="#+id/encoreLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:maxHeight="#dimen/thumbnail_height"
android:maxWidth="#dimen/thumbnail_width"
android:scaleType="centerInside"
android:src="#drawable/hand72" />
<TextView
android:id="#+id/logInText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/encoreLogo"
android:layout_alignLeft="#+id/passwordField"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_marginBottom="79dp"
android:paddingLeft="#dimen/left_padding_login_text"
android:text="Login to Encore"
android:textColor="#android:color/white"
android:textSize="#dimen/log_in_text"
android:textStyle="bold"
android:visibility="invisible" />
<EditText
android:id="#+id/emailField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/encoreLogo"
android:layout_centerHorizontal="true"
android:layout_marginBottom="18dp"
android:background="#drawable/rounded_corners"
android:ems="10"
android:inputType="textEmailAddress"
android:hint="Email"
android:textColor="#android:color/black"
android:textStyle="italic"
android:visibility="invisible" />
<EditText
android:id="#+id/passwordField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/encoreLogo"
android:layout_centerHorizontal="true"
android:background="#drawable/rounded_corners"
android:ems="10"
android:inputType="textPassword"
android:hint="Password"
android:textStyle="italic"
android:textColor="#android:color/black"
android:visibility="invisible" />
<Button
android:id="#+id/signupButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/loginButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp"
android:background="#android:color/transparent"
android:text="#string/signUp"
android:textColor="#5FC2FF"
android:textSize="#dimen/signupText"
android:textStyle="bold"
android:visibility="invisible" />
<Button
android:id="#+id/loginButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/passwordField"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:background="#android:color/transparent"
android:text="#string/login"
android:textColor="#android:color/white"
android:textSize="#dimen/signupText"
android:visibility="invisible" />
Thanks in advance!
So it seems that when you have the visibility set to INVISIBLE on the EditText fields it doesn't want to get focus.
I fixed this issue by changing the visibility on those fields after the animation completes like this:
animFadeIn.setAnimationListener(new AnimationListener() {
#Override
public void onAnimationEnd(Animation animation) {
emailField.setVisibility(View.VISIBLE);
passwordField.setVisibility(View.VISIBLE);
logInText.setVisibility(View.VISIBLE);
loginButton.setVisibility(View.VISIBLE);
signupButton.setVisibility(View.VISIBLE);
}
#Override
public void onAnimationStart(Animation animation) {}
#Override
public void onAnimationRepeat(Animation animation) {}
});
Hope this helps you :)
It seems like you want to wait for the image (logo) to finish its animation then start the animations for TextView and EditView. Instead of using setAnimationListener what you can do is set the start offset value of animFadeIn to 4000 miliseconds.
Try this:
TranslateAnimation animation = new TranslateAnimation(0.0f, 00f,
0.0f, -400.0f);
animation.setDuration(4000);
animation.setFillAfter(true);
animation.setStartOffset(2000);
img_animation.startAnimation(animation);
Animation animFadeIn = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
animFadeIn.setDuration(2000);
animFadeIn.setStartOffset(4000);
animFadeIn.setFillAfter(true);
emailField.setAnimation(animFadeIn);
passwordField.setAnimation(animFadeIn);
logInText.setAnimation(animFadeIn);
loginButton.setAnimation(animFadeIn);
signupButton.setAnimation(animFadeIn);
The keyboard opens up fine for me.
Had the same problem. Just don't use fillAfter, it's crap. Combine with #Wextux's solution.
There are different types of Animations,
You are using the wrong type of animation! You want to use ObjectAnimator.
Related
I am currently creating android app. I have a login activity in which on top there is LinearLayout with ImageViewand below it there is GirdLayout where there are few EditTexts. I would like to move my LinearLayout to given height when any of the EditTexts has focus. I was trying the solution from here:
Android translate animation - permanently move View to new position using AnimationListener and put AnimationListener inside of onFocusChange, but in my case it appears to do nothing. Could You help me?
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="6"
android:background="#74B897"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/imageLayout"
>
<ImageView
android:layout_width="247dp"
android:layout_height="290dp"
android:id="#+id/logo_imageView"
android:layout_alignParentTop="true"
android:layout_gravity="center_horizontal"
android:layout_row="1"
android:src="#drawable/white_logo" />
</LinearLayout>
<GridLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#drawable/layout_shape"
android:layout_weight="2"
android:layout_row="7"
android:layout_column="1"
android:weightSum="5"
android:layout_below="#+id/logo_imageView"
android:layout_marginLeft = "15dp"
android:layout_marginRight = "15dp"
android:layout_marginBottom = "30dp"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/fname_editText"
android:hint="First Name"
android:layout_rowWeight="0"
android:layout_marginTop = "15dp"
android:layout_row="1"
android:layout_column="0"
android:textColor="#FFFFFF"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/sname_editText"
android:layout_below="#+id/fname_editText"
android:hint="Second Name"
android:layout_rowWeight="0"
android:layout_row="2"
android:layout_column="0"
android:textColor="#FFFFFF"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/password_editText"
android:inputType="textPassword"
android:ems="10"
android:hint="Password"
android:layout_rowWeight="0"
android:layout_row="3"
android:layout_column="0"
android:textColor="#FFFFFF"/>
<Button
android:layout_width="141dp"
android:text="Log In"
android:id="#+id/log_button"
android:background="#drawable/button_shape"
android:layout_marginTop="10dp"
android:layout_marginBottom="40dp"
android:layout_below="#+id/id_editText"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:layout_rowWeight="1"
android:textSize="20dp"
android:textStyle="bold"
android:layout_row="5"
android:layout_column="0"
android:layout_height="29dp"
android:textColor="#636363" />
</GridLayout>
</LinearLayout>
Activity:
public class LoginActivity extends Activity implements View.OnFocusChangeListener{
EditText sname;
EditText password;
TextView info;
ImageView img;
EditText fname;
LinearLayout imageLayout;
int oldX, oldY, newX, newY;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_layout);
fname = (EditText) findViewById(R.id.fname_editText);
sname = (EditText)findViewById(R.id.sname_editText);
password = (EditText)findViewById(R.id.password_editText);
img= (ImageView) findViewById(R.id.logo_imageView);
imageLayout = (LinearLayout) findViewById(R.id.imageLayout);
oldX = imageLayout.getWidth();
oldY = imageLayout.getHeight();
img.setImageResource(R.drawable.white_logo);
Button log_Button = (Button) findViewById(R.id.log_button);
fname.setFocusable(true);
sname.setFocusable(true);
password.setFocusable(true);
}
#Override
public void onFocusChange(View v, boolean hasFocus) {
if(v.getId() == R.id.fname_editText || v.getId() == R.id.sname_editText || v.getId() == R.id.password_editText)
{
final ObjectAnimator moveDownAnim = ObjectAnimator.ofFloat(imageLayout, "translationY", 0.F, -300);
final ObjectAnimator moveUpAnim = ObjectAnimator.ofFloat(imageLayout, "translationY", 300, 0.F);
if(hasFocus){
//first option
moveDownAnim.start();
/*
second option
TranslateAnimation anim = new TranslateAnimation(0, 0, 0, -300);
anim.setFillAfter(false);
anim.setDuration(1000);
anim.setAnimationListener(new TranslateAnimation.AnimationListener() {
#Override
public void onAnimationStart(Animation animation) {
}
#Override
public void onAnimationRepeat(Animation animation) {
}
#Override
public void onAnimationEnd(Animation animation) {
imageLayout.clearAnimation();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) imageLayout.getLayoutParams();
params.topMargin += -300;
imageLayout.setLayoutParams(params);
animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, -300);
animation.setDuration(1);
imageLayout.startAnimation(animation);
}
});
imageLayout.startAnimation(anim);*/
}
}
}
}
I don't see you setting the OnFocusChangeListener for the EditTexts in your code.
fname.setOnFocusChangeListener(this);
sname.setOnFocusChangeListener(this);
I'm using Slide Up/Down Animation for my four TextView. Following is my XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/shadow"
android:orientation="vertical"
android:weightSum="2.0" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" >
<TextView
android:id="#+id/textViewblue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_marginLeft="25dp"
android:background="#drawable/blue"
android:gravity="center"
android:text="blue" />
<TextView
android:id="#+id/textVieworange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_marginRight="25dp"
android:background="#drawable/orange"
android:gravity="center"
android:text="orange" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0">
<TextView
android:id="#+id/textViewpink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="25dp"
android:background="#drawable/pink"
android:gravity="center"
android:text="pink" />
<TextView
android:id="#+id/textViewgreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:layout_marginRight="25dp"
android:background="#drawable/green"
android:gravity="center"
android:text="green" />
</RelativeLayout>
</LinearLayout>
and Following is my Class
public class HomeScreenActivity extends Activity implements OnClickListener {
TextView textViewblue, textVieworange, textViewpink,
textViewgreen;
Animation mAnimation_up, mAnimation_down;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
mAnimation_up = new TranslateAnimation(
TranslateAnimation.RELATIVE_TO_SELF, 0f,
TranslateAnimation.RELATIVE_TO_SELF, 0f,
TranslateAnimation.RELATIVE_TO_SELF, 1.6f,
TranslateAnimation.RELATIVE_TO_SELF, 0f);
mAnimation_up.setDuration(1000);
mAnimation_up.setRepeatCount(-1);
mAnimation_up.setRepeatMode(Animation.REVERSE);
mAnimation_up.setInterpolator(new LinearInterpolator());
mAnimation_down = new TranslateAnimation(
TranslateAnimation.RELATIVE_TO_SELF, 0f,
TranslateAnimation.RELATIVE_TO_SELF, 0f,
TranslateAnimation.RELATIVE_TO_SELF, 0f,
TranslateAnimation.RELATIVE_TO_SELF, 1.6f);
mAnimation_down.setDuration(1000);
mAnimation_down.setRepeatCount(-1);
mAnimation_down.setRepeatMode(Animation.REVERSE);
mAnimation_down.setInterpolator(new LinearInterpolator());
initialize();
}
private void initialize() {
textViewblue = (TextView) findViewById(R.id.textViewblue);
textVieworange = (TextView) findViewById(R.id.textVieworange);
textViewpink = (TextView) findViewById(R.id.textViewpink);
textViewgreen = (TextView) findViewById(R.id.textViewgreen);
textViewblue .setOnClickListener(this);
textVieworange .setOnClickListener(this);
textViewpink .setOnClickListener(this);
textViewgreen .setOnClickListener(this);
textViewblue .setAnimation(mAnimation_down);
textViewpink .setAnimation(mAnimation_down);
textVieworange .setAnimation(mAnimation_up);
textViewgreen .setAnimation(mAnimation_up);
}
#Override
public void onClick(View v) {
Intent intentmenu;
switch (v.getId()) {
case R.id.textViewblue:
Toast.makeText(this, "blue", Toast.LENGTH_LONG).show();
break;
case R.id.textVieworange:
Toast.makeText(this, "orange", Toast.LENGTH_LONG).show();
break;
case R.id.textViewpink:
Toast.makeText(this, "pink", Toast.LENGTH_LONG).show();
break;
case R.id.textViewgreen:
Toast.makeText(this, "reeng", Toast.LENGTH_LONG).show();
break;
}
}
}
The problem is that when any TextViewslide for int position means when animation starts the onClickListener works only at its XML position not for its updated position.
Please suggest me the solution for that, how can I detect the updated position for to detect onClickListener on TextView.
Thanks.
Maybe that's a bit complicated to make it. As you're using View animation system, the behavior is under expectation. Although the Views are translated to other places, they're just being
drawn there. From the system's perspective, they're in fact always at the original place where you define in xml file. If you want the click event at the new place, you should use the new property animation system.
The onClickListener is not working because views are shifted from their original place due to animation. To solve this create a same layout below your animation and initially make its Gravity as GONE and when your animation finishes up make its Gravity as Visible and your animation layout visibility as Gone.
also be careful that all the id's of animation and original layout would not be same.
I am trying to animate an ImageView with a background image. The animation loads fine during the first time but after that becomes laggy and no animation appears.
file ---- main.xml
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="31dp"
/>
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/editText1"
android:layout_marginRight="30dp"
android:layout_marginTop="52dp"
android:text="Click me" />
file ---- TutorialActivity.java
private isClicked = 0;
private Animation animUp;
private Animation animDown;
animUp = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
animDown = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
animUp.setDuration(500);
animDown.setDuration(500);
Button clickButton = (Button) findViewById(R.id.button2);
clickButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v)
{
if(isClicked == 0)
{
menu.setVisibility(View.VISIBLE);
menu.setAnimation(animUp);
isClicked = 1;
}
else
{
menu.setAnimation(animDown);
menu.setVisibility(View.GONE);
isClicked = 0;
}
}
Every time you use animation you should set animation start time. Any way you prefer, from simple animation.startNow() to more complex animation.setStartTime(time); animation.start().
I am trying to make an animation with two textviews. Both are in a relative layout. The functionality of the animation is left textview will go little bit left and at the same time right textview will also go little bit left. I have tried:
http://nineoldandroids.com/ and default way.
But for both case I am getting a gap during the process. I already put one question but i am not getting any positive reply:
Android slider animation is not synchronized
Nineoldandroids code:
xml file:
<RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/target"
android:layout_marginTop="50dp">
<TextView
android:id="#+id/TextView01"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:background="#f00"
android:gravity="center"
android:text="RED"
android:textColor="#000" />
<Button
android:id="#+id/TextView02"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_alignBottom="#+id/TextView01"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/TextView01"
android:background="#0F0"
android:text="TXT"
android:visibility="invisible" />
</RelativeLayout>
MainActivity.java:
public class MainActivity extends Activity {
double counter = 0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.toggles);
final View target = findViewById(R.id.target);
final int duration = 5*1000;
final int duration1 = 300;
final View textView1 = findViewById(R.id.TextView01);
final View textView2 = findViewById(R.id.TextView02);
textView1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (counter == 0) {
textView2.setVisibility(View.VISIBLE);
ObjectAnimator.ofFloat(textView1, "translationX", 0, -50).setDuration(duration1).start();
ObjectAnimator.ofFloat(textView2, "translationX", 100, 0).setDuration(duration1).start();
counter++;
}
else {
ObjectAnimator.ofFloat(textView1, "translationX", -50,0).setDuration(duration1).start();
ObjectAnimator.ofFloat(textView2, "translationX", 0,100).setDuration(duration1).start();
counter--;
}
}
});
}
}
How can I fix it?
otherwise I am trying to put both textview inside a layout where second textview will be outside the screen and using the animation I will move the whole layout. how can I make the xml like this?
Sorry for misunderstanding your question.
Anyway, your issue is not about time exactly. Both animations have the same duration but the problem is the sizes of the animated regions are different. Logically, moving a longer distance in the same duration will look slower than moving a smaller distance.
For example, to solve your problem, I used the following code in the OnClickListener:
public void onClick(View v) {
int width =textView2.getWidth();
if (counter == 0) {
textView2.setVisibility(View.VISIBLE);
ObjectAnimator.ofFloat(textView1, "translationX", 0, -1*width).setDuration(duration1).start();
ObjectAnimator.ofFloat(textView2, "translationX", 1*width, 0).setDuration(duration1).start();
counter++;
}
else {
ObjectAnimator.ofFloat(textView1, "translationX", -1*width, 0).setDuration(duration1).start();
ObjectAnimator.ofFloat(textView2, "translationX", 0, 1*width).setDuration(duration1).start();
counter--;
}
}
Try this
<!-- YOUR CONTAINER -->
<LinearLayout
android:id="#+id/target"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/target"
android:layout_marginTop="50dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/TextView01"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:background="#f00"
android:gravity="center"
android:text="RED"
android:textColor="#000" />
<Button
android:id="#+id/TextView02"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_alignBottom="#+id/TextView01"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/TextView01"
android:background="#0F0"
android:text="TXT"
android:visibility="invisible" />
</LinearLayout>
Then use a ViewPropertyAnimator like this (if you can use it)
//Translate your view -50 to the left.
yourLinearLayout.animate().translationX(-50).setDuration(1000);
With the ObjectAnimator I achieved the same results by using this code
Button textView02 = (Button) findViewById(R.id.textView02);
LinearLayout target = (LinearLayout) findViewById(R.id.target);
int width = textView02.getWidth();
ObjectAnimator.ofFloat(target, "translationX", 0, -width).setDuration(1000).start();
Hope this helps you
I want to change the background image and TextView Color on click of a layout .The background color is chnaging properly but my textview color is not changing.Here is my XML code :
<RelativeLayout
android:id="#+id/flight_relative"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_below="#+id/imgLogo"
android:layout_marginTop="5dp"
android:background="#drawable/button_effect"
android:gravity="center_vertical" >
<TextView
android:id="#+id/flight_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/flight_list_image"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/flight_list_image"
android:text="#string/flight_tittle"
android:textColor="#152b72"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="#+id/content_flight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/flight_content"
android:layout_toRightOf="#+id/flight_list_image"
android:text="#string/flight_content"
android:textColor="#2f2f2f"
android:textSize="10sp" />
<ImageView
android:id="#+id/flight_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/flight_content"
android:layout_alignParentRight="true"
android:src="#drawable/arrow" />
<ImageView
android:id="#+id/flight_list_image"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="3dip"
android:src="#drawable/flight_icon" />
</RelativeLayout>
Code to chnage the textview color is :
flightRelative = (RelativeLayout )findViewById(R.id.flight_relative);
flightRelative.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
flight = (TextView)findViewById(R.id.flight_content);
flight.setTextColor(Color.WHITE);
}
});
What wrong i am doing please suggest me .For the first time it is not working on second time it is working
You should add this definitely working.I am also check it out...
flightRelative.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
TextView flight = (TextView)findViewById(R.id.flight_content);
flight.setTextColor(Color.parseColor("#FFFFFF"));
}
});
you should use
#Override
public void onClick(View arg0) {
flight = (TextView)flightRelative.findViewById(R.id.flight_content);
flight.setTextColor(Color.WHITE);
}
I believe it should work now.