我的应用包含许多活动。当用户午餐时,应用程序显示包含带按钮的表的主要活动。如果用户按下其中一个按钮,应用程序将转到另一个活动,每个按钮代表活动。在其中一个活动中,用户将按下按钮以执行两个功能: 1-发送两个字符串变量和一个int。 2-午餐另一项活动。 在活动中,用户将编辑数据,之后用户将按下按钮以实现两个功能: 1-向主活动发送两个字符串变量和一个int(用于在表中显示)。 2-午餐主要活动。
我的问题是,三个变量中有一个(它是新手)在桌面上显示出来。我尝试过使用Intent或Bundle发送的方式。
主要活动
condi_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, CONDIMENT.class);
startActivity(q);
finish();
}
});
egg_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, EGG.class);
startActivity(q);
finish();
}
});
fast_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, FAST.class);
startActivity(q);
finish();
}
});
fish_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, FISH_CHECKEN.class);
startActivity(q);
finish();
}
});
fruit_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, FRUIT.class);
startActivity(q);
finish();
}
});
meat_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, MEAT.class);
startActivity(q);
finish();
}
});
milk_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, MILK.class);
startActivity(q);
finish();
}
});
mooca_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, MOOCA.class);
startActivity(q);
finish();
}
});
oil_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, OIL_FAT.class);
startActivity(q);
finish();
}
});
rice_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, RICE_BREAD.class);
startActivity(q);
finish();
}
});
vege_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent q = new Intent(MainActivity.this, VEGETABLE.class);
startActivity(q);
finish();
}
});
众多活动之一:
fas001add.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
Intent a = new Intent(FAST.this,Add.class);
a.putExtra("cal", Content.Fast001.calory);
a.putExtra("con", Content.Fast001.consist);
a.putExtra("meal", Content.Fast001.meal);
startActivity(a);
}});
所有按钮都相同
用户在将数据发送到主活动后对数据进行编辑的活动 在这里接收:
Intent n = this.getIntent();
nam =n.getExtras().getString("meal");
con = n.getExtras().getString("con");
cal =n.getExtras().getInt("cal");
这里编辑:
add14.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
add14.setBackgroundResource(R.drawable.calorybuttonplus);
add13.setBackgroundResource(R.drawable.calorybutton);
add12.setBackgroundResource(R.drawable.calorybutton);
add1.setBackgroundResource(R.drawable.calorybutton);
add15.setBackgroundResource(R.drawable.calorybutton);
add2.setBackgroundResource(R.drawable.calorybutton);
mul= 0.25 ;
}});
add13.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
add14.setBackgroundResource(R.drawable.calorybutton);
add13.setBackgroundResource(R.drawable.calorybuttonplus);
add12.setBackgroundResource(R.drawable.calorybutton);
add1.setBackgroundResource(R.drawable.calorybutton);
add15.setBackgroundResource(R.drawable.calorybutton);
add2.setBackgroundResource(R.drawable.calorybutton);
mul=0.33 ;
}});
add12.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
add14.setBackgroundResource(R.drawable.calorybutton);
add13.setBackgroundResource(R.drawable.calorybutton);
add12.setBackgroundResource(R.drawable.calorybuttonplus);
add1.setBackgroundResource(R.drawable.calorybutton);
add15.setBackgroundResource(R.drawable.calorybutton);
add2.setBackgroundResource(R.drawable.calorybutton);
mul = 0.5;
}});
add1.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
add14.setBackgroundResource(R.drawable.calorybutton);
add13.setBackgroundResource(R.drawable.calorybutton);
add12.setBackgroundResource(R.drawable.calorybutton);
add1.setBackgroundResource(R.drawable.calorybuttonplus);
add15.setBackgroundResource(R.drawable.calorybutton);
add2.setBackgroundResource(R.drawable.calorybutton);
mul =1.0000;
}});
add15.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
add14.setBackgroundResource(R.drawable.calorybutton);
add13.setBackgroundResource(R.drawable.calorybutton);
add12.setBackgroundResource(R.drawable.calorybutton);
add1.setBackgroundResource(R.drawable.calorybutton);
add15.setBackgroundResource(R.drawable.calorybuttonplus);
add2.setBackgroundResource(R.drawable.calorybutton);
mul =1.5;
}});
add2.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
add14.setBackgroundResource(R.drawable.calorybutton);
add13.setBackgroundResource(R.drawable.calorybutton);
add12.setBackgroundResource(R.drawable.calorybutton);
add1.setBackgroundResource(R.drawable.calorybutton);
add15.setBackgroundResource(R.drawable.calorybutton);
add2.setBackgroundResource(R.drawable.calorybuttonplus);
mul= 2.000;
}});
beak.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
beak.setBackgroundResource(R.drawable.calorybuttonplus);
lun.setBackgroundResource(R.drawable.calorybutton);
din.setBackgroundResource(R.drawable.calorybutton);
sna.setBackgroundResource(R.drawable.calorybutton);
fmeal="فطور";
}});
lun.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
beak.setBackgroundResource(R.drawable.calorybutton);
lun.setBackgroundResource(R.drawable.calorybuttonplus);
din.setBackgroundResource(R.drawable.calorybutton);
sna.setBackgroundResource(R.drawable.calorybutton);
fmeal ="غداء";
}});
din.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
beak.setBackgroundResource(R.drawable.calorybutton);
lun.setBackgroundResource(R.drawable.calorybutton);
din.setBackgroundResource(R.drawable.calorybuttonplus);
sna.setBackgroundResource(R.drawable.calorybutton);
fmeal ="عشاء";
}});
sna.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
beak.setBackgroundResource(R.drawable.calorybutton);
lun.setBackgroundResource(R.drawable.calorybutton);
din.setBackgroundResource(R.drawable.calorybutton);
sna.setBackgroundResource(R.drawable.calorybuttonplus);
fmeal ="وجبة خفيفة ";
}});
这里发送:
addf.setOnClickListener(new OnClickListener (){
@Override
public void onClick(View v) {
try {
cal_mul = (double) cal;
cal = (int) (cal_mul * mul);
Intent o = new Intent(Add.this, MainActivity.class);
o.putExtra("kind", fmeal);
o.putExtra("calory",cal);
o.putExtra("namee", nam);
startActivity(o);
}
catch (Exception e)
{
Toast.makeText(getBaseContext(),"الرجاء اكمال الخيارات",Toast.LENGTH_LONG).show();
}
}});
main activity receiving (here is the problem)
try {
Intent g = this.getIntent();
newcm =g.getExtras().getInt("calory");
newkindm= g.getExtras().getString("kind");
newnamem= g.getExtras().getString("namee");
if (meal1 == false) {
cm1 = newcm;
kindm1 = newkindm;
namem1 = newnamem;
meal1 = true;
sumf = sumf + cm1;
kindmu1.setText(kindm1);
calmu1.setText(cm1);
summanu.setText(sumf);
namemu11.setText(namem1);
}
if (meal1 == true & meal2 == false) {
meal2 = true;
cm2 = newcm;
kindm2 = newkindm;
namem2 = newkindm;
sumf = sumf + newcm;
}
if (meal2 == true & meal3 == false) {
meal3 = true;
cm3 = newcm;
kindm3 = newkindm;
namem3 = newkindm;
sumf = sumf + newcm;
}
if (meal3 == true & meal4 == false) {
meal4 = true;
cm4 = newcm;
kindm4 = newkindm;
namem4 = newkindm;
sumf = sumf + newcm;
}
if (meal4 == true & meal5 == false) {
meal5 = true;
cm5 = newcm;
kindm5 = newkindm;
namem5 = newkindm;
sumf = sumf + newcm;
}
if (meal5 == true & meal6 == false) {
meal6 = true;
cm6 = newcm;
kindm6 = newkindm;
namem6 = newkindm;
sumf = sumf + newcm;
}
if (meal6 == true & meal7 == false) {
meal7 = true;
cm7 = newcm;
kindm7 = newkindm;
namem7 = newkindm;
sumf = sumf + newcm;
}
if (meal7 == true & meal8 == false) {
meal8 = true;
cm8 = newcm;
kindm8 = newkindm;
namem8 = newkindm;
sumf = sumf + newcm;
}
if (meal8 == true & meal9 == false) {
meal9 = true;
cm9 = newcm;
kindm9 = newkindm;
namem9 = newkindm;
sumf = sumf + newcm;
}
if (meal9 == true & meal10 == false) {
meal10 = true;
cm10 = newcm;
kindm10 = newkindm;
namem10 = newkindm;
sumf = sumf + newcm;
}
if (meal10 == true & meal11 == false) {
meal11 = true;
cm11 = newcm;
kindm11 = newkindm;
namem11 = newkindm;
sumf = sumf + newcm;
}
if (meal11 == true & meal12 == false) {
meal12 = true;
cm12 = newcm;
kindm12 = newkindm;
namem12 = newkindm;
sumf = sumf + newcm;
}
if (meal12 == true & meal13 == false) {
meal13 = true;
cm13 = newcm;
kindm13 = newkindm;
namem13 = newkindm;
sumf = sumf + newcm;
}
if (meal13 == true & meal14 == false) {
meal14 = true;
cm14 = newcm;
kindm14 = newkindm;
namem14 = newkindm;
sumf = sumf + newcm;
}
if (meal14 == true & meal15 == false) {
meal15 = true;
cm15 = newcm;
kindm15 = newkindm;
namem15 = newkindm;
sumf = sumf + newcm;
}
if (meal15 == true & meal16 == false) {
meal16 = true;
cm16 = newcm;
kindm16 = newkindm;
namem16 = newkindm;
sumf = sumf + newcm;
}
if (meal16 == true & meal17 == false) {
meal17 = true;
cm17 = newcm;
kindm17 = newkindm;
namem17 = newkindm;
sumf = sumf + newcm;
}
if (meal17 == true & meal18 == false) {
meal18 = true;
cm18 = newcm;
kindm18 = newkindm;
namem18 = newkindm;
sumf = sumf + newcm;
}
if (meal18 == true & meal19 == false) {
meal19 = true;
cm19 = newcm;
kindm19 = newkindm;
namem19 = newkindm;
sumf = sumf + newcm;
}
} catch (Exception e) {
}
答案 0 :(得分:1)
似乎dlopen失败了: 如果您要dlopen的库不在标准搜索路径中,则您有许多选项:
在dlopen中指定文件的完整路径
的dlopen(" /full/path/to/libfile.so"); 通过LD_LIBRARY_PATH
添加到库的路径LD_LIBRARY_PATH = / path / to / library / ./executable 使用ld -rpath选项将库路径添加到应用程序。
g ++ -link stuff- -Wl,-rpath = / path / to / library / 请注意选项1& 3将库路径硬编码到您的应用程序中。 -rpath可以选择指定相对路径,即
-Wl,-rpath = $ ORIGIN /../ LIB / 将嵌入相对路径的应用程序。
试试吧。