I'm a novice programmer and I'm practicing creating screens and other things, including a ListView. The case is that I created 3 activities, the second screen (Activity) is linked to a third one that says nothing and I wanted to take advantage of that to create the Adapter class there, but the AS does not allow it, because it is a different class from AppCompatActivity. I need to create a different class? Can I link that Adapter class with the second activity?
Thank you!
This would be the second screen
public class SecondActivity extends AppCompatActivity {
private Button acepto, noacepto;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
acepto= (Button) findViewById(R.id.bacepto);
noacepto=(Button)findViewById(R.id.bnacepto);
acepto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SecondActivity.this, ThirdActivity.class);
startActivity(intent);
finish();
}
});
noacepto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(SecondActivity.this, "Debes aceptar las condiciones para avanzar", Toast.LENGTH_SHORT).show();
//(MainActivity.this, "Los campos estan vacios", Toast.LENGTH_SHORT).show();
}
});
}
}
Which brings me to this, where I have a TextView in the XML (Adapter_a3) that says "Product List"
![]()
public class ThirdActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.Adapter_a3);
}
}
What I want to do is write the adapter code in this Activity, to be able to link it to the same Adapter_a3 layout (the a3 is from Activity 3, so as not to get lost)
public class Adapter extends BaseAdapter {
@Override
public int getCount() {
return 0;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return null;
}
}
But he will not let me ... I do not know if I explained myself well