Found 2041 Articles for Mobile Development

What is difference between FillParent and wrap content in android?

Azhar
Updated on 02-Jul-2020 07:32:16

2K+ Views

This example demonstrates how do I show the difference between fillParent and wrap content in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step 4 − Add the following code to androidManifest.xml ... Read More

How to prevent a dialog from closing when a button is clicked?

Azhar
Updated on 02-Jul-2020 07:32:53

2K+ Views

This example demonstrates how do I prevent a dialog from closing when a button is clicked.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       final AlertDialog dialog = new ... Read More

How to set a particular font for a button text in Android?

Azhar
Updated on 02-Jul-2020 07:35:39

933 Views

This example demonstrates how do I set a particular font for a button text in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javaimport android.graphics.Typeface; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import static android.graphics.Typeface.BOLD_ITALIC; public class MainActivity extends AppCompatActivity {    Button btnChangeFont, btnChangeFont2;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main); ... Read More

How to get selected Index of the Radio group in Android?

Azhar
Updated on 02-Jul-2020 07:36:13

3K+ Views

This example demonstrates how do I get selected index of the radio group in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                             Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    Button button;    RadioGroup radioGroup;   ... Read More

How do I remove lines between listviews on Android?

Azhar
Updated on 02-Jul-2020 07:39:12

255 Views

This example demonstrates how do I remove lines between listviews on android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; public class MainActivity extends AppCompatActivity {    ListView listView;    String[] mobilePhones = new String[] { "Samsung", "Iphone",    "Nokia", "Alcatel", "Blackberry", "Oppo", "Sony"};    @Override    protected void onCreate(Bundle savedInstanceState) {     ... Read More

How to use XMLPullParser to parse XML in Android?

Azhar
Updated on 02-Jul-2020 07:21:53

673 Views

This example demonstrates how do I XMLPullParser in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 – Right click in the res/layout and create a layout resource file(row.xml) and add the following code −             Step 4 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleAdapter; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import java.io.IOException; import java.io.InputStream; ... Read More

How to pass values between Fragments in Android?

Azhar
Updated on 02-Jul-2020 07:35:03

1K+ Views

This example demonstrates how do I pass values between fragments in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends AppCompatActivity implements FragmentOne.OnFragmentInteractionListener{    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    @Override    public boolean onCreateOptionsMenu(Menu menu) {     ... Read More

How to use JSONobject to parse JSON in Android?

Azhar
Updated on 02-Jul-2020 07:22:27

365 Views

This example demonstrates how do I use JSONObject to parse JSON in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import org.json.JSONException; import org.json.JSONObject; public class MainActivity extends AppCompatActivity {    public static final String JSON_STRING="{\"Employee\":{\"Name\":\"Niyaz\", \"Salary\":56000}}";    TextView textView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);   ... Read More

Web scrapping in Android application

Azhar
Updated on 02-Jul-2020 07:23:00

4K+ Views

This example demonstrates how do I do web scrapping in android application.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 – Open build.gradle(Mobule:app) and add the following dependencyimplementation 'org.jsoup:jsoup:1.11.2'Step 3 − Add the following code to res/layout/activity_main.xml.         Step 4 − Add the following code to src/MainActivity.javaimport android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import java.io.IOException; public class MainActivity extends AppCompatActivity {    TextView textView;    Button button;    @Override ... Read More

How to get and store Device ID in Android?

Azhar
Updated on 02-Jul-2020 07:38:37

2K+ Views

This example demonstrates how do I get and store Device ID in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.import android.provider.Settings; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = findViewById(R.id.textView);       String ID = Settings.Secure.getString(getContentResolver(),       Settings.Secure.ANDROID_ID);       textView.setText("Device ID: ... Read More

Advertisements