[Solved] SharedPreferences Save value of Int in a TextView

I explained where I made changes public class MainActivity extends Activity { Button search; TextView tvRing; //Making sharedpreferences and integers global for ease of use private SharedPreferences prefs; private int redRing, someint; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); search = (Button) findViewById(R.id.radar); tvRing = (TextView) findViewById(R.id.ring); //Someint default value is 0 if not … Read more

[Solved] App crashes when accessing multiple textviews from navigation header

As it’s in the NavigationView try navigationView.findViewById(viewId); A strange thing I faced while I am using NavigationView is sometimes navigationView.findViewById(viewId) return null (reason may be we try to access (header) view before they are inflated to NavigationView) Now I used to add manually header to NavigationView View header = LayoutInflater.from(this).inflate(R.layout.header_layout, null); navigationView.addHeaderView(header); TexView title = … Read more

[Solved] Unable to pass data between fragments…..TextView throws NullPoint Exception

You should call text=(TextView)view.findViewById(R.id.tt); onCreateView(), or in the method that is called from onCreateView() before doing anything with it. If text hasn’t been assigned to UI element, TextView throws NullPoint Exception. If you really want that assigning in another method, write a method like private void initUI() 5 solved Unable to pass data between fragments…..TextView … Read more

[Solved] Java/XML – Change TextView

Code to change the textview‘s text through java code should contain at least one TextView object to start with. I can not see that in your code. But I am writing below a sample code for that. setContentView(R.layout.activity_main); TextView txtView = (TextView) findViewById(R.id.txtview); txtView.setText(“This is changed text”); Your activity_main.xml should contain TextView defined with id … Read more

[Solved] How to pass a text from one activity to all activities?

Just store the text as string in shared preferences and then get the string in other activities.. or you can also use broadcast receiver in all other activities. But first all the activities should call the receiver first then the MainActivity can send the text. In MainActivity, this.getSharedPreferences(“MyPrefName”, Context.MODE_PRIVATE).edit().putString(“parsetext”,”yourtext”).apply(); and in the other activities.. this.getSharedPreferences(“MyPrefName”, … Read more

[Solved] How to show the input text view in Android

Edit: <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:background=”@color/myBackground” tools:context=”.MainActivity” android:selectAllOnFocus=”true”> <ImageView android:id=”@+id/imageView1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:layout_marginTop=”20dp” android:src=”https://stackoverflow.com/questions/16164469/@drawable/voicemeno” /> <TextView android:id=”@+id/userName” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:layout_marginTop=”40dp” android:layout_below=”@+id/imageView1″ android:text=”User Name” android:textAppearance=”?android:attr/textAppearanceMedium” android:textColor=”@color/myText” /> <EditText android:id=”@+id/userNameInput” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:layout_marginTop=”5dp” android:layout_below=”@+id/userName” android:ems=”10″ android:inputType=”textPersonName” android:textColor=”@color/myText” android:textCursorDrawable=”@null” > </EditText> <TextView android:id=”@+id/password” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:layout_marginTop=”40dp” android:layout_below=”@+id/userNameInput” android:text=”Password” android:textAppearance=”?android:attr/textAppearanceMedium” android:textColor=”@color/myText” /> <EditText android:id=”@+id/passwordInput” … Read more

[Solved] How to format single textview like below in android without using \n or html format?

You can do it programmatically using this function val text = “This is my first text view this is my second textview this is my third textview” textView.text = proxyWifi.textFormation(text) copy/paste this code do your project 🙂 public String textFormation(String text){ String result = “”; String[] sentenceWords = text.split(” “); List<String> newSentenceWords = new ArrayList<>(); … Read more