0
Может ли кто-нибудь мне помочь? У меня проблемы с этим. Мне нужны кнопки для перемещения. У кого-нибудь есть схожая проблема?Перемещение нескольких кнопок?
public class MainActivity extends Activity {
Button[] b = null;
Intent[] intent=null;
TranslateAnimation[] trans;
Typeface font;
ImageView plavi,ljubicasti;
AnimationDrawable plavian,ljubicastian;
int i=0,f=2000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Class[] naslovi = {
First.class,
Second.class,
Third.class,
Fourth.class,
Fifth.class};
font = Typeface.createFromAsset(getAssets(),"FatMarker.ttf");
b = new Button[]
{
(Button) findViewById(R.id.button1),
(Button) findViewById(R.id.button2),
(Button) findViewById(R.id.button3),
(Button) findViewById(R.id.button4),
(Button) findViewById(R.id.button5),
};
intent = new Intent[b.length];
for(i=0;i<5;i++)
{
intent[i] = new Intent(MainActivity.this,naslovi[i]);
b[i].setTag(i);
b[i].setOnClickListener(new Button.OnClickListener() {
public void onClick(View v)
{
startActivity(intent[(Integer)v.getTag()]);
Toast.makeText(getApplicationContext(), "Loading ...",
Toast.LENGTH_SHORT).show();
}
});
b[i].setTypeface(font);
trans[i] = new TranslateAnimation(0, 0, f, 0);
trans[i].setDuration(f);
b[i].startAnimation(trans[i]);
b[i].setVisibility(View.VISIBLE);
f=f+250;
}
}
}