Use Marquee Text in an Android App

Azhar
Updated on 03-Jul-2020 05:58:21

385 Views

This example demonstrates how do I use Marquee text in an android app.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; public class MainActivity extends AppCompatActivity{    TextView textMarquee;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textMarquee = findViewById(R.id.textMarquee);       textMarquee.setText("Be the change that you ... Read More

Set OnClickListener on a Radio Button in Android

Azhar
Updated on 03-Jul-2020 05:56:54

2K+ Views

This example demonstrates how do I set OnclickListener on a radio button 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.Toast; public class MainActivity extends AppCompatActivity {    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } ... Read More

Convert ISO 8601 String to Date Time Object in Android

Azhar
Updated on 03-Jul-2020 05:53:39

2K+ Views

This example demonstrates how do I convert ISO 8601 string to date/time object 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 java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = findViewById(R.id.textView); ... Read More

Disable Leaf of JTree in Java

raja
Updated on 03-Jul-2020 05:46:15

406 Views

A JTree is a component that presents a hierarchical view of data. The user has the ability to expand or collapse individual sub-trees. A TreeNode interface defines the methods that must be implemented nodes of a JTree object. The DefaulMutableTreeNode class provides a default implementation of a TreeNode interface. We can disable the leaf of JTree by overriding the getTreeCellRendererComponent() method of DefaultTreeCellRenderer class.Syntaxpublic Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)Exampleimport java.awt.*; import javax.swing.tree.*; import javax.swing.*; public class JTreeLeafNodeDisableTest extends JFrame {    private TreeNode treeNode;    private JTree tree;    public JTreeLeafNodeDisableTest() {       setTitle("JTreeLeafNodeDisable Test");     ... Read More

Draw a Smooth Line Following Your Finger in Android

Azhar
Updated on 03-Jul-2020 05:41:07

773 Views

This example demonstrates how do I draw a smooth line following my finger 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.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; public class MainActivity extends AppCompatActivity implements View.OnTouchListener {    ImageView imageView;    Bitmap bitmap;    Canvas canvas;    Paint paint;    float downX = ... Read More

Dynamically Set the Position of View in Android

Azhar
Updated on 03-Jul-2020 05:37:34

3K+ Views

This example demonstrates how do I 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.RelativeLayout; import android.widget.TextView; public class MainActivity extends AppCompatActivity{    Button button;    TextView textView;    RelativeLayout relativeLayout;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       relativeLayout = ... Read More

Control Height and Width of Default Alert Dialog in Android

Azhar
Updated on 03-Jul-2020 05:36:17

6K+ Views

This example demonstrates how do I control the height and width of the default alert dialog 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.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.WindowManager; import android.widget.Button; import android.widget.RelativeLayout;    public class MainActivity extends AppCompatActivity{       Button button;       RelativeLayout relativeLayout;       Context ... Read More

Pass ArrayList to Another Activity Using Intents in Android

Azhar
Updated on 03-Jul-2020 05:35:34

9K+ Views

This example demonstrates how do I pass an arrayList to another activity using intends 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.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import java.util.ArrayList; public class MainActivity extends AppCompatActivity{    Button button;    ArrayList numbers = new ArrayList();    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       ... Read More

Sell Your Bitcoin: A Step-by-Step Guide

Prasanna Kotamraju
Updated on 02-Jul-2020 15:26:36

305 Views

Already own bitcoins but want either just exchange with some conventional currency or simply get rid of them considering them mere a bubble of widening hype. However, it is not as easy as buying them. Got lines of stress on your forehead? Do not worry! Here is the complete guide for your easy comprehension of the entire process −There are two ways to sell your bitcoins −ExchangesDirect TradeExchange Although, this carries a number of disadvantages yet exchanges appear to be one of the major solutions if you want cash out of the selling of your crypto. These exchanges play the role ... Read More

Print Custom Message Instead of Error Stack Trace in Java

Maruthi Krishna
Updated on 02-Jul-2020 15:03:02

4K+ Views

An exception is an issue (run time error) occurred during the execution of a program. When an exception occurred the program gets terminated abruptly and, the code past the line that generated the exception never gets executed.Printing the Exception messageYou can print the exception message in Java using one of the following methods which are inherited from Throwable class.printStackTrace() − This method prints the backtrace to the standard error stream.getMessage() − This method returns the detail message string of the current throwable object.toString() − This message prints the short description of the current throwable object.Exampleimport java.util.Scanner; public class PrintingExceptionMessage { ... Read More

Advertisements