我想将点击的行翻译为活动上的textview。 我已经尝试了下面的代码,但视图没有翻译并移动到活动屏幕。
public PopupWindow popupWindowDogs() {
RelativeLayout viewGroup = (RelativeLayout) findViewById(R.id.relative1);
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.layout,viewGroup);
// Creating the PopupWindow
popupWindow = new PopupWindow(getBaseContext());
popupWindow.setContentView(layout);
listViewDogs = (ListView)layout.findViewById(R.id.listView10);
// set our adapter and pass our pop up window contents
listViewDogs.setAdapter(dogsAdapter(popUpContents));
listViewDogs.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
c = (TextView) view.findViewById(R.id.title);
final String playerChanged = c.getText().toString();
////////
final float growTo = 1.1f;
final long duration = 1000;
TranslateAnimation anim = new TranslateAnimation(v.getX(), txt.getX(), v.getY(), txt.getY());
AnimationSet growAndShrink = new AnimationSet(true);
growAndShrink.setInterpolator(new AccelerateInterpolator());
growAndShrink.addAnimation(anim);
growAndShrink.setFillAfter(true);
view.startAnimation(growAndShrink);
growAndShrink.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
popupWindowDogs.dismiss();
txt.setText(playerChanged);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
});
// some other visual settings
popupWindow.setFocusable(true);
popupWindow.setWidth(250);
popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
// set the list view as pop up window content
popupWindow.setContentView(listViewDogs);
return popupWindow;
}
答案 0 :(得分:0)
也许您可以尝试更改view.startAnimation(growAndShrink);
和growAndShrink.setAnimationListener(new Animation.AnimationListener() { ... });
的顺序首先将所有内容设置为growAndShrink动画,然后再启动动画。我认为它可能不会进入AnimationListener并且永远不会调用txt.setText(playerChanged);
。你觉得怎么样?