PaddyAreaText.java 1.79 KB
Newer Older
Binuka Sihan's avatar
Binuka Sihan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
package com.example.eketha.PaddyArea;

import androidx.appcompat.app.AppCompatActivity;

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 com.example.eketha.FertilizerGuidence;
import com.example.eketha.R;

public class PaddyAreaText extends AppCompatActivity {

    EditText paddyValue;
    Button addPaddyValue,navigateFertiGuidence;
    private String fertilizerType;
    private String areaResult;

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

        paddyValue = findViewById(R.id.paddyValue);
        addPaddyValue = findViewById(R.id.addPaddyValue);
        navigateFertiGuidence = findViewById(R.id.navigateFertiGuidence);
        fertilizerType = getIntent().getStringExtra("fertilizerType");

        navigateFertiGuidence.setEnabled(false);

        addPaddyValue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplicationContext(),paddyValue.getText(), Toast.LENGTH_SHORT).show();
                areaResult = paddyValue.getText().toString();
                navigateFertiGuidence.setEnabled(true);
            }
        });

        navigateFertiGuidence.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(PaddyAreaText.this, FertilizerGuidence.class);
                intent.putExtra("fertilizerType",fertilizerType);
                intent.putExtra("areaResult",areaResult);
                startActivity(intent);
            }
        });
    }
}