i have a listactivity app , each row cotain TEXT and BUTTON , both text and button must be clickable (what im try to get it ) , when click the text it will open MyDay activity and when click button it will open My_videos activity .
whats happen exactly when you open the app and click on any button , it do no click action in any button in all rows , but when you click any row text so it will open MyDay activity then click any button in the first row ONLY , it will open My_videos activity which is videoview , but in the same time the other buttons is not clickable in the rest of rows .
any advice will be appreciated ,
THANKS.
MY CODE :
MyArrayAdapter Class:
public class MyArrayAdapter extends ArrayAdapter<String> {
private final Activity context;
private final String[] classes;
Button bt1, bt2, bt3, bt4, bt5;
Typeface tf;
public MyArrayAdapter(Activity context, String[] classes) {
super(context, R.layout.row, classes);
this.context = context;
this.classes = classes;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
tf=Typeface.createFromAsset(context.getAssets(),"BFantezy.ttf");
LayoutInflater inflater = context.getLayoutInflater();
View rowView = inflater.inflate(R.layout.row, null, true);
TextView textView = (TextView) rowView.findViewById(R.id.row_label);
Button bt1=(Button) rowView.findViewById(R.id.button1);
Button bt2=(Button) rowView.findViewById(R.id.button2);
Button bt3=(Button) rowView.findViewById(R.id.button3);
Button bt4=(Button) rowView.findViewById(R.id.button4);
Button bt5=(Button) rowView.findViewById(R.id.button5);
String s = classes[position];
textView.setText(s);
((TextView)textView).setTypeface(tf);
if ( s.startsWith("First")) {
bt1.setBackgroundResource(R.drawable.ic_launcher);
bt2.setBackgroundResource(R.drawable.ic_launcher);
bt3.setBackgroundResource(R.drawable.ic_launcher);
bt4.setBackgroundResource(R.drawable.ic_launcher);
bt5.setBackgroundResource(R.drawable.ic_launcher); }
if ( s.startsWith("Second")) {
bt1.setBackgroundResource(R.drawable.ic_launcher);
bt2.setBackgroundResource(R.drawable.ic_launcher);
bt3.setBackgroundResource(R.drawable.ic_launcher);
bt4.setBackgroundResource(R.drawable.ic_launcher);
bt5.setBackgroundResource(R.drawable.ic_launcher); }
if ( s.startsWith("Third")) {
bt1.setBackgroundResource(R.drawable.ic_launcher);
bt2.setBackgroundResource(R.drawable.ic_launcher);
bt3.setBackgroundResource(R.drawable.ic_launcher);
bt4.setBackgroundResource(R.drawable.ic_launcher);
bt5.setBackgroundResource(R.drawable.ic_launcher); }
if ( s.startsWith("Fourth")) {
bt1.setBackgroundResource(R.drawable.ic_launcher);
bt2.setBackgroundResource(R.drawable.ic_launcher);
bt3.setBackgroundResource(R.drawable.ic_launcher);
bt4.setBackgroundResource(R.drawable.ic_launcher);
bt5.setBackgroundResource(R.drawable.ic_launcher); }
if ( s.startsWith("Fifth")) {
bt1.setBackgroundResource(R.drawable.ic_launcher);
bt2.setBackgroundResource(R.drawable.ic_launcher);
bt3.setBackgroundResource(R.drawable.ic_launcher);
bt4.setBackgroundResource(R.drawable.ic_launcher);
bt5.setBackgroundResource(R.drawable.ic_launcher); }
return rowView; }}
My_videos Class:
public class My_videos extends Activity {
private VideoView vid;
String night;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video);
Bundle bdl = getIntent().getExtras();
night = bdl.getString("video");
vid = (VideoView) findViewById(R.id.videoView1);
if (night.equalsIgnoreCase("button1")) {
vid.setVideoURI(Uri.parse("android.resource://" + getPackageName()
+ "/" + R.raw.b));
vid.setMediaController(new MediaController(My_videos.this));
vid.requestFocus();
vid.start(); }
else if (night.equalsIgnoreCase("button2")) {
vid.setVideoURI(Uri.parse("android.resource://" + getPackageName()
+ "/" + R.raw.bb));
vid.setMediaController(new MediaController(My_videos.this));
vid.requestFocus();
vid.start(); }
else if (night.equalsIgnoreCase("button3")) {
vid.setVideoURI(Uri.parse("android.resource://" + getPackageName()
+ "/" + R.raw.bbb));
vid.setMediaController(new MediaController(My_videos.this));
vid.requestFocus();
vid.start(); }
else if (night.equalsIgnoreCase("button4")) {
vid.setVideoURI(Uri.parse("android.resource://" + getPackageName()
+ "/" + R.raw.bbbb));
vid.setMediaController(new MediaController(My_videos.this));
vid.requestFocus();
vid.start(); }
else if (night.equalsIgnoreCase("button5")) {
vid.setVideoURI(Uri.parse("android.resource://" + getPackageName()
+ "/" + R.raw.bbbbb));
vid.setMediaController(new MediaController(My_videos.this));
vid.requestFocus();
vid.start(); }
} }