0% found this document useful (0 votes)
7 views4 pages

pr18 MAD

The document contains Android XML layout code and Java code for a simple application. It features a user interface with an EditText for URL input and a Button that opens the URL in a web browser when clicked. Additionally, there is a layout for a button to dial a number, demonstrating basic UI components in Android development.

Uploaded by

mmaa68436843
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

pr18 MAD

The document contains Android XML layout code and Java code for a simple application. It features a user interface with an EditText for URL input and a Button that opens the URL in a web browser when clicked. Additionally, there is a layout for a button to dial a number, demonstrating basic UI components in Android development.

Uploaded by

mmaa68436843
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

<?xml version="1.0" encoding="utf-8"?> package com.example.

pr18_1;
<LinearLayout import android.annotation.SuppressLint;
import android.content.Intent;
xmlns:android="http://schemas.android.com/apk/res/and import android.net.Uri;
roid" import android.os.Bundle;
android:layout_width="match_parent" import android.view.View;
android:layout_height="match_parent" import android.widget.Button;
android:layout_weight="1" import android.widget.EditText;
android:orientation="vertical"> import
androidx.appcompat.app.AppCompatActivity;
<EditText public class MainActivity extends AppCompatActivity
android:id="@+id/et1" {
android:layout_width="match_parent" EditText et1;
android:layout_height="50dp" /> Button btn;
@SuppressLint("MissingInflatedId")
<Button @Override
android:id="@+id/btn" protected void onCreate(Bundle
android:layout_width="match_parent" savedInstanceState) {
android:layout_height="50dp" super.onCreate(savedInstanceState);
android:text="Submit" /> setContentView(R.layout.activity_main);
</LinearLayout> et1=findViewById(R.id.et1);
btn=findViewById(R.id.btn);
btn.setOnClickListener(v->
{
String url=et1.getText().toString();
Intent intent=new
Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);

});

}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/an xmlns:android="http://schemas.android.com/apk/res
droid" /android"
xmlns:app="http://schemas.android.com/apk/res- xmlns:app="http://schemas.android.com/apk/res-
auto" auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">

<!-- Button to trigger dialing --> <!-- Button to trigger dialing -->
<Button <Button
android:id="@+id/btn" android:id="@+id/btn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Dial Number" android:text="Dial Number"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"

app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintBottom_toBottomOf="parent"/
>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout
>

You might also like