I'm trying to write an android game,
I want my person on the view would dance when I press.
and have a score keep gaining during the pressing.
how can i solve the score problem ?
Can timer help ?
And how's the difference between onlongclick and onclick ?
here is my code:
package com.example.test;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.support.v4.app.NavUtils;
import android.text.Layout;
public class pi extends Activity {
OnTouchListener listen1;
RelativeLayout f1;
int count = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pi);
listen1 = new OnTouchListener() {
private TextView txt;
@Override
public boolean onTouch(View v, MotionEvent event) {
txt = (TextView)findViewById(R.id.textView1);
txt.setText("aaaaa");
return false;
}
};
f1 = (RelativeLayout)findViewById(R.id.titlescreenframe);
f1.setOnTouchListener(listen1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_pi, menu);
return true;
}
}