<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: SHREEHITH REDDY</title>
    <description>The latest articles on DEV Community by SHREEHITH REDDY (@shreehith_reddy_f05c3a6bc).</description>
    <link>https://dev.to/shreehith_reddy_f05c3a6bc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2898849%2F7511fa8d-2e6e-4467-94d7-9df0da3d8e39.png</url>
      <title>DEV Community: SHREEHITH REDDY</title>
      <link>https://dev.to/shreehith_reddy_f05c3a6bc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shreehith_reddy_f05c3a6bc"/>
    <language>en</language>
    <item>
      <title>phone dailer app in android studio (java &amp; xml)</title>
      <dc:creator>SHREEHITH REDDY</dc:creator>
      <pubDate>Wed, 26 Feb 2025 07:21:59 +0000</pubDate>
      <link>https://dev.to/shreehith_reddy_f05c3a6bc/phone-dailer-app-in-android-studio-java-xml-499h</link>
      <guid>https://dev.to/shreehith_reddy_f05c3a6bc/phone-dailer-app-in-android-studio-java-xml-499h</guid>
      <description>&lt;p&gt;mainactivity.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Main Activity



package com.example.phonedailer;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private EditText phoneNumber;
    private Spinner callTypeSpinner;
    private Button callButton, saveButton;
    private String selectedCallType;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        phoneNumber = findViewById(R.id.phoneNumber);
        callTypeSpinner = findViewById(R.id.callTypeSpinner);
        callButton = findViewById(R.id.callButton);
        saveButton = findViewById(R.id.saveButton);

        // Populate spinner with call types
        String[] callTypes = {"Voice Call", "Video Call", "WhatsApp Call"};
        ArrayAdapter&amp;lt;String&amp;gt; adapter = new ArrayAdapter&amp;lt;&amp;gt;(this, android.R.layout.simple_spinner_dropdown_item, callTypes);
        callTypeSpinner.setAdapter(adapter);

        // Capture selected call type
        callTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView&amp;lt;?&amp;gt; parent, View view, int position, long id) {
                selectedCallType = callTypes[position];
            }

            @Override
            public void onNothingSelected(AdapterView&amp;lt;?&amp;gt; parent) {
                selectedCallType = "Voice Call";
            }
        });

        // Call Button Click
        callButton.setOnClickListener(v -&amp;gt; {
            String number = phoneNumber.getText().toString().trim();
            if (isValidPhoneNumber(number)) {
                Toast.makeText(MainActivity.this, number + " " + selectedCallType + " initiating...", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MainActivity.this, "Invalid Number", Toast.LENGTH_SHORT).show();
            }
        });

        // Save Button Click
        saveButton.setOnClickListener(v -&amp;gt; {
            String number = phoneNumber.getText().toString().trim();
            if (isValidPhoneNumber(number)) {
                Toast.makeText(MainActivity.this, number + " saved.", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MainActivity.this, "Invalid Number", Toast.LENGTH_SHORT).show();
            }
        });
    }

    // Phone number validation (10 digits only)
    private boolean isValidPhoneNumber(String number) {
        return number.matches("\\d{10}");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;activity.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.XML


&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="20dp"
    android:orientation="vertical"
    android:gravity="center"&amp;gt;

    &amp;lt;!-- Phone Number Input --&amp;gt;
    &amp;lt;EditText
        android:id="@+id/phoneNumber"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter phone number"
        android:inputType="number"
        android:maxLength="10"
        android:textSize="18sp"
        android:padding="10dp"
        android:background="@android:drawable/edit_text" /&amp;gt;

    &amp;lt;!-- Spinner for Call Type Selection --&amp;gt;
    &amp;lt;Spinner
        android:id="@+id/callTypeSpinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:padding="5dp" /&amp;gt;

    &amp;lt;!-- Call Button --&amp;gt;
    &amp;lt;Button
        android:id="@+id/callButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Call"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:background="@android:color/holo_blue_light"
        android:textColor="@android:color/black"
        android:textSize="18sp" /&amp;gt;

    &amp;lt;!-- Save Button --&amp;gt;
    &amp;lt;Button
        android:id="@+id/saveButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Save"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:background="@android:color/holo_green_light"
        android:textColor="@android:color/black"
        android:textSize="18sp" /&amp;gt;

&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>expense tracker with tab layout (java &amp; XML)</title>
      <dc:creator>SHREEHITH REDDY</dc:creator>
      <pubDate>Wed, 26 Feb 2025 07:19:14 +0000</pubDate>
      <link>https://dev.to/shreehith_reddy_f05c3a6bc/expense-tracker-with-tab-layout-5440</link>
      <guid>https://dev.to/shreehith_reddy_f05c3a6bc/expense-tracker-with-tab-layout-5440</guid>
      <description>&lt;p&gt;main.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Main (XML)

&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"&amp;gt;

    &amp;lt;com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="fixed"
        app:tabGravity="fill" /&amp;gt;

    &amp;lt;androidx.viewpager.widget.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/tabLayout"/&amp;gt;

    &amp;lt;FrameLayout
        android:id="@+id/fragmentContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"/&amp;gt;
&amp;lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;main.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Main.java

package com.example.expensetracker;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;

public class MainActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private TabLayout tabLayout;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        viewPager = findViewById(R.id.viewPager);
        tabLayout = findViewById(R.id.tabLayout);

        TabAdapter adapter = new TabAdapter(getSupportFragmentManager());
        adapter.addFragment(new IncomeFragment(), "Income");
        adapter.addFragment(new ExpenseAdapter(), "Expenses");

        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;tabactivity.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TabActivity.java

package com.example.expensetracker;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.ArrayList;
import java.util.List;

public class TabAdapter extends FragmentPagerAdapter {

    private final List&amp;lt;Fragment&amp;gt; fragmentList = new ArrayList&amp;lt;&amp;gt;();
    private final List&amp;lt;String&amp;gt; fragmentTitleList = new ArrayList&amp;lt;&amp;gt;();

    public TabAdapter(FragmentManager fm) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
    }

    public void addFragment(Fragment fragment, String title) {
        fragmentList.add(fragment);
        fragmentTitleList.add(title);
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return fragmentTitleList.get(position);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;incomefragment.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IncomeFragment.java

ckage com.example.expensetracker;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.fragment.app.Fragment;

public class IncomeFragment extends Fragment {
    private EditText incomeInput;
    private Button submitButton;
    private int totalIncome = 0;
    private int totalExpenses = 0;  // To store expenses received from ExpensesFragment

    public IncomeFragment() {
        super(R.layout.activity_income_fragment);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        incomeInput = view.findViewById(R.id.incomeInput);
        submitButton = view.findViewById(R.id.submitButton);

        // Receiving expenses from ExpensesFragment
        if (getArguments() != null) {
            totalExpenses = getArguments().getInt("totalExpenses", 0);
        }

        submitButton.setOnClickListener(v -&amp;gt; {
            String incomeText = incomeInput.getText().toString();
            if (!incomeText.isEmpty()) {
                totalIncome = Integer.parseInt(incomeText);
                Toast.makeText(getContext(), "Income: ₹" + totalIncome, Toast.LENGTH_SHORT).show();

                // Sending data to SummaryActivity
                Intent intent = new Intent(getActivity(), SummaryActivity.class);
                intent.putExtra("totalIncome", totalIncome);
                intent.putExtra("totalExpenses", totalExpenses);
                startActivity(intent);
            } else {
                Toast.makeText(getContext(), "Please enter a valid income!", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;incomefragment.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IncomeFragment (XML)

&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp"
    android:gravity="center"
    &amp;gt;

    &amp;lt;EditText
        android:id="@+id/incomeInput"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter Income"
        android:inputType="number"/&amp;gt;

    &amp;lt;Button
        android:id="@+id/submitButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Submit"/&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;expenseadapter.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ExpenseAdapter.java

package com.example.expensetracker;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.fragment.app.Fragment;

public class ExpenseAdapter extends Fragment {
    private EditText rentInput, groceriesInput, billsInput, transportInput;
    private Button calculateButton;
    private int totalExpenses = 0;

    public ExpenseAdapter() {
        super(R.layout.activity_expense_adapter);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        rentInput = view.findViewById(R.id.rent);
        groceriesInput = view.findViewById(R.id.groceries);
        billsInput = view.findViewById(R.id.bills);
        transportInput = view.findViewById(R.id.transport);
        calculateButton = view.findViewById(R.id.calculateButton);

        calculateButton.setOnClickListener(v -&amp;gt; {
            int rent = getInputValue(rentInput);
            int groceries = getInputValue(groceriesInput);
            int bills = getInputValue(billsInput);
            int transport = getInputValue(transportInput);

            totalExpenses = rent + groceries + bills + transport;
            Toast.makeText(getContext(), "Total Expenses: ₹" + totalExpenses, Toast.LENGTH_SHORT).show();

            // Sending expenses to IncomeFragment
            Bundle bundle = new Bundle();
            bundle.putInt("totalExpenses", totalExpenses);
            IncomeFragment incomeFragment = new IncomeFragment();
            incomeFragment.setArguments(bundle);

            requireActivity().getSupportFragmentManager().beginTransaction()
                    .replace(R.id.fragmentContainer, incomeFragment)
                    .commit();
        });
    }

    private int getInputValue(EditText editText) {
        String text = editText.getText().toString();
        return text.isEmpty() ? 0 : Integer.parseInt(text);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;expenseadapter.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ExpenseAdapter (XML)

&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="20dp"&amp;gt;

    &amp;lt;EditText
        android:id="@+id/rent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter Rent"
        android:inputType="number" /&amp;gt;

    &amp;lt;EditText
        android:id="@+id/groceries"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter Groceries Expense"
        android:inputType="number" /&amp;gt;

    &amp;lt;EditText
        android:id="@+id/bills"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter Bills Expense"
        android:inputType="number" /&amp;gt;

    &amp;lt;EditText
        android:id="@+id/transport"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter Transport Expense"
        android:inputType="number" /&amp;gt;

    &amp;lt;Button
        android:id="@+id/calculateButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Calculate Expenses"
        android:backgroundTint="@color/black"
        android:textColor="@android:color/white"
        android:layout_marginTop="20dp"/&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;summary.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Summary.java

package com.example.expensetracker;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class SummaryActivity extends AppCompatActivity {
    private TextView summaryText;
    private int totalIncome, totalExpenses;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_summary);

        summaryText = findViewById(R.id.summaryText);

        // Receiving data from IncomeFragment
        Intent intent = getIntent();
        if (intent != null) {
            totalIncome = intent.getIntExtra("totalIncome", 0);
            totalExpenses = intent.getIntExtra("totalExpenses", 0);

        }



        int difference = totalIncome - totalExpenses;
        Toast.makeText(this, "Remaining Balance: ₹" + difference, Toast.LENGTH_LONG).show();

        summaryText.setText("Income: ₹" + totalIncome + "\nExpenses: ₹" + totalExpenses+"\nBalance: "+difference);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;summary.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Summary (XML)

&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp"&amp;gt;

    &amp;lt;TextView
        android:id="@+id/summaryText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Summary"
        android:textSize="18sp"
        android:textStyle="bold"/&amp;gt;
&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
