[Solved] Finishing activities A & B from activity B and go to activity C in android

The better solution is, you should replace startActivity() with startActivityForResult() for activity transition. And from logout userActivity you just set a result and you will get onActivityResult in your mainActivity if you handle it properly.Then you can simply finish mainActivity. Refer https://developer.android.com/training/basics/intents/result.html Another way is finish MainActivity from its onResume, if the activity onResume is … Read more

[Solved] switch a Button and Get a different at the Bottom

Create a new Fragment that describes what you want to do in each pane. For example, import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class ButtonOneFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container != null) { container.removeAllViews(); } return inflater.inflate(R.layout.button_one_fragment, container, false); } public void … Read more

[Solved] Android app crashes by switching the activity

Replace R.id.tvFeed with Framelayout’s id or default id android.R.id.content. if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(android.R.id.content, new PlaceholderFragment()) .commit(); } and remove the code from the onOptionsItemSelected() method. if (id == R.id.tvFeed) { return true; } solved Android app crashes by switching the activity

[Solved] Define a value to EditText

Use this. If (edittext.getText().toString()==myPreProgrammedString){ start next activity } else{ show warning wrong password } Usually you would put something like this in a onClick method of a login button. But I use something similar in textwatchers afterTextChanged method to check if the entered text is in a list and then enable the OK button. BTW: … Read more

[Solved] what happens on returning previous activity?

Activity A and Activity B, When you move from Activity A to Activity B the lifecycle is as follows Activity A ——————– onCreate() //A onStart() //A onResume() //A – here user can interact with UI(buttons,views), user click button and it moves to second activity onPause() //A ——————– onCreate() //Activity B onStart() //B onResume() //B ——————– … Read more

[Solved] Variables to next activity [duplicate]

Pass value of string to Activity2: button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String a = editText.getText().toString(); String b = editText2.getText().toString(); Intent intent = new Intent(your_activity.this, Activity2.class); intent.putExtra(“a_value”, a); intent.putExtra(“b_value”, b); startActivity(intent); } }); Retrieve the value in 2nd Activity: public String user1; public String user2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); … Read more

[Solved] How to access a HashMap from another class

Either make the information available by using statics (not recommended), use some kind of database (could be as simple as a text file) or pass an Intent along with your Activity. A nice tutorial on adding information to an Intent is found here: http://startandroid.ru/en/lessons/complete-list/241-lesson-28-extras-passing-data-using-intent.html 0 solved How to access a HashMap from another class

[Solved] Android Studio API 22 gives an error Unfortunately, “App Name” has stopped working after successful build [duplicate]

Try removing the android prefix in <item name=”android:windowNoTitle”>true</item> i.e replace it with <item name=”windowNoTitle”>true</item>. Also replace <style name=”MyMaterialTheme.Base” parent=”Theme.AppCompat.Light.DarkActionBar”> with <style name=”MyMaterialTheme.Base” parent=”Theme.AppCompat”> , the Light.DarkActionBar part is unnecessary as you are specifying windowActionbar as false and windowNoTitle as true and setting action bar in activity. Also one more thing, ActionBarActivity is deprecated in revision … Read more

[Solved] What is an Activity in Android? [closed]

Can anyone please explain what is exactly an ‘Activity’ means in Android ? An activity is your main “coarse” unit of user interface. It is roughly analogous to a screen, page, window, or other similar construct in other GUI environments. Or, to quote the documentation: An Activity is an application component that provides a screen … Read more

[Solved] How to create layout like in this image? [closed]

Not sure is this what you want. You may try. <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal” android:gravity=”start” android:background=”@android:color/white” android:padding=”12dp”> <ImageView android:id=”@+id/image” android:layout_width=”80dp” android:layout_height=”70dp” android:layout_centerVertical=”true” android:layout_gravity=”left”/> <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_toRightOf=”@+id/image” android:layout_centerVertical=”true” android:paddingLeft=”6dp” android:orientation=”vertical” android:layout_alignParentRight=”true” android:layout_alignParentEnd=”true”> <LinearLayout android:id=”@+id/ll1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <TextView android:id=”@+id/name” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:textSize=”18sp” android:text=”Depeche Mode” android:singleLine=”true” /> </LinearLayout> <LinearLayout android:id=”@+id/ll2″ android:layout_below=”@+id/ll1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <TextView … Read more

[Solved] Exception on Date parsing android [duplicate]

Your date format MM/dd/yyyy’T’HH:mm:ss which your using is incorrect 1/31/2018 8:58:12 AM +00:00 and return different value from expected. SimpleDateFormat sdf = new SimpleDateFormat(“MM/dd/yyyy’T’HH:mm:ss”); return 1/31/2018T8:58:12 And you are trying to pass below 1/31/2018 8:58:12 AM +00:00 1 solved Exception on Date parsing android [duplicate]

[Solved] How to handle a large number of activities in android studio

No, you don’t need that many activities. You need to write abstract activities that take parameters and displays different data based on those. At most I see 4 activities here- department selector, semester selector, subject selector, and the actual subject activity. And arguably some of those should be fragments instead, although that’s more personal choice. … Read more

[Solved] How to pass data from activity to class in android? [closed]

Create a class for your requirement as CustomView and define public method to pass integer value and use it there. As I have created setIntValue(). public class CustomView extends View { private int mIntValue; public CustomView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public CustomView(Context context, AttributeSet attrs) { this(context, attrs, 0); … Read more