[Solved] How to change the activity background from fragment inside it [closed]

Use like this: class Main extends FragmentActivity { public ImageView imageView; @Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.main); imageView = (ImageView)findViewById(R.id.ivMain); } } class Demo extends Fragment { Main main; public void onAttach(Activity activity) { main = (Main) activity; }; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { main.imageView.setBackgroundColor(color); return super.onCreateView(inflater, container, … Read more

[Solved] Algorithm for quantity selection [closed]

You should have a Product class. Each product object has different quantity measures and increment methods. Something like this: public abstract class Product { String quantityMeasure; //You can encapsulate this with a getter public abstract int step (int value); //here you want to increment “value” with different algorithms. } Now you can create different product … Read more

[Solved] getActivity() From Fragment to Fragment returning null

adapter.setOnItemClickListner(new DailyMenuFrag()); The new DailyMenuFrag() here is a new fragment and it is not attached to any activity and hence getActivity() returns null. Looks like you should use adapter.setOnItemClickListner(this); instead to use the current DailyMenuFrag instance as item click listener. solved getActivity() From Fragment to Fragment returning null

[Solved] Start Activity after a period of time [duplicate]

I want to start a new activity after a period of time on button click en.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //… new Handler().postDelayed(new Runnable() { @Override public void run() { startActivity(new Intent(LanguageActivity.this, ServicesActivity.class)); } }, 5 * 1000); // 5 seconds } }); solved Start Activity after a period of time … Read more

[Solved] How to get data from fragment to another activity? (Not container activity) [duplicate]

if you’re routing from fragment to another activity, you can put you data into the intent using the putExtra and then receive in the activity using getExtra. Inside the fragment, Intent profileActivityIntent = new Intent(context,ProfileActivity.class); profileActivityIntent.putExtra(“dataKey”,data); startActivity(profileActivityIntent); And then inside the ProfileActivity’s onCreate method, //assuming that data is a string String dataFromFragment = getIntent().getStringExtra(“dataKey”); Log.i(“Data … Read more

[Solved] Start and Close single Activity from BroadcastReceiver

You could try to directly kill an activity by calling a static method in that activity: Activity A should have a variable static ActivityA activityA; In onCreate state: activityA = this; and add this method: public static ActivityA getInstance(){ return activityA; } In activity B, call the fuction getInstance() ActivityA.getInstance().finish(); solved Start and Close single … Read more

[Solved] How to forward my application on login activity after pressing on logout button? [closed]

Try this for your concern Intent intent = new Intent(CurrentClass.this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); For ex: Say you have back button named “back” back.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(CurrentClass.this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); 0 solved How to forward my application … Read more

[Solved] How to convert textview as link in android?

You have to setOnTouchListener to the TextView. Here I give you an example: public class MainActivity extends Activity implements View.OnTouchListener { private TextView tv1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv1 = (TextView) findViewById(R.id.tv1); tv1.setOnTouchListener(this); } @Override public boolean onTouch(View v, MotionEvent event) { // HERE YOU HAVE TO CHECK WHICH ID IS … Read more