Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my activity class,

public class StatusActivity extends AppCompatActivity {


    private boolean cFlag = false;

    public boolean getFlag() { return cFlag;  }

    public void setFlag(boolean cFlag) {
        this.cFlag = cFlag;
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);
        adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, 
                                      android.R.id.text1, messages);
        ListView listView = findViewById(android.R.id.list);
        listView.setAdapter(adapter);
        adapters.add(adapter);


        Button btn = findViewById(R.id.btnCustomerCheckIn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setFlag(true);
                cFlag = getFlag();


                Intent intent = new Intent(StatusActivity.this, MainActivity.class);
                Toast.makeText(StatusActivity.this, "customer checked in", 
                                Toast.LENGTH_LONG).show();
                startActivity(intent);
            }
        });


    }


this is a part of another class named as position
public class Position {
    StatusActivity statusactivity = new StatusActivity();
    public  boolean ccflag = statusactivity.getFlag();
    statusactivity.setFlag(false);

    }


What I have tried:

when i am calling
statusactivity.setFlag(false);
it is showing an error. couldn't recognize that what is the error that i am getting. but
statusactivity.getFlag(); 
is working properly. any help is appreciated
Posted
Updated 13-Nov-18 22:04pm
Comments
Richard MacCutchan 14-Nov-18 3:23am    
What error? Why do so many developers think that the details of the error are not important?

1 solution

1. put cFlag set method and get method in object class.
2. Extends Position class to Activity
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900