当我在当前活动中按下按钮时,如何更改下一个活动背景
how to change next activity background when i press button in current activity
当我在当前活动中按下按钮时,我想更改下一个活动的背景&我有32个按钮,所有的都会进行相同的活动,但我想根据按钮的排列来改变它的背景,所以它会改变32次。我尝试了这个,但它不起作用
buttons[0].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","fattetl3bet");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back1);
}
});
buttons[1].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","sikkarwasat");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back254);
}
});
buttons[2].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","superfamily");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2978);
}
});
buttons[3].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","wiladaminalkhasira1");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back27);
}
});
buttons[4].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","wiladaminalkhasira2");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back280);
}
});
buttons[5].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","wiladaminalkhasira3");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back278);
}
});
buttons[6].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","zamanlbarghout1");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back278);
}
});
buttons[7].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","zamanlbarghout2");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back278);
}
});
buttons[8].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","ta7ounalchar1");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2896);
}
});
buttons[9].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","ta7ounalchar2");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back287);
}
});
buttons[10].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","sar5troo7");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2879);
}
});
buttons[11].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","sabaya1");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2789);
}
});
buttons[12].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","sabaya2");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back234);
}
});
buttons[13].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","sabaya3");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2435);
}
});
buttons[14].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","sabaya4");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2345);
}
});
buttons[15].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","sabaya5");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2435);
}
});
buttons[16].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","sana3oud");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2345);
}
});
buttons[17].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","ta7tasama2alwatan");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2435);
}
});
buttons[18].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","natrin");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back26546);
}
});
buttons[19].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","7oudoudchakika");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2546);
}
});
buttons[20].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","yasmin3atik");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2546);
}
});
buttons[21].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","znoodelset");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back2546);
}
});
buttons[22].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(Sori.this,listnameseries.class);
myIntent.putExtra("namemovies","l3btmoot");
startActivity(myIntent);
buttons[0].setBackgroundResource(R.drawable.back25464);
}
});
为您的意图添加额外的内容,例如资源id
myIntent.putExtra("resource_id", R.color.myPreferedBackground);
然后在onCreate()中的下一个活动中:
int bg = getIntent.getIntExtra("resource_id");
myLayout.setBackgroundResource(bg);
将有关颜色的信息与意图一起发送到下一个活动。
在下一个活动"创建"中,根据信息更改颜色。
相关文章:
- 后焦点更改为IE 11中的地址栏,而不是转移到表单中的下一个控件
- 正如我所能做的引导提醒,按下一个按钮可以更改语言
- 如何使用 asp.net 中的另一个下拉列表更改下拉列表选定的索引和可见性
- Jquery-更改下一个按钮的行为
- Chrome(Android)键盘将单词转移到js焦点更改的下一个输入
- 使用JQuery将焦点更改为粘贴事件后的下一个输入
- 使用angularjs将焦点更改为下一个输入文本
- 更改移动到phonegap中的下一个活动的风格-移动android
- 如何使用javascript和jquery在按下下一个和上一个按钮时更改文本值
- 如何在组合框值更改时自动重定向下一个 jsp 页面
- 正则表达式根据下一个单词将 a 更改为 a
- 如何在同一页面上使用下一个和上一个按钮更改内容
- 使用条形码扫描仪将焦点从一个输入更改为下一个输入
- 当我在当前活动中按下按钮时,如何更改下一个活动背景
- 更改下一个select元素的类名
- 单击更改下一个TD表
- 如何使用Jquery更改图像大小和更改下一个/前一个图像
- 选项选择可动态更改下一个选择
- 超时后如何更改下一个图像
- 如何更改"下一个"和"上一个"按钮上的标题