İki liste görünümüne sahip olduğum bir etkinliğim var.Aynı anda ilerlemek için iki liste görünümü istiyorum
Biri, resim görüntüleme ve metin görünümü insdie ile özel bir liste görünümüdür ve kaydırma çözümünü bulduktan sonra bir düğme olacaktır.
Temel olarak sol, yiyecekler için bir listedir ve resmi ve sağ tarafı satın almak için bir listedir.
Artık bunları aynı anda kaydırırken sorun yaşıyorum.
public class list_activity extends AppCompatActivity {
String[] itemname ={
"Safari",
"Camera",
"Global",
"FireFox",
"UC Browser",
"Android Folder",
"VLC Player",
"Cold War",
"Whatsapp",
"Google",
"Java"
};
String[] buy={"one","two","two","two","two","two","two","two","two","two","two","two","two","two","two","two","two"};
Context context = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_food_list);
ListAdapter adapter = new com.example.azaabudeen.restoapp.CustomListView(this,itemname);
ListView listView= (ListView)findViewById(R.id.listview);
ListView secondlistview= (ListView)findViewById(R.id.foodlistBuyButton);
ListAdapter secondA= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,buy);
secondlistview.setAdapter(secondA);
listView.setAdapter(adapter);
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.view);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String currentItem= String.valueOf(parent.getItemAtPosition(position));
Toast.makeText(list_activity.this,currentItem,Toast.LENGTH_SHORT).show();
/// final TextView text = (TextView)findViewById(R.id.text);
/// final Button myButton=(Button)findViewById(R.id.dialogButtonOK);
/// text.setText("Image of the list");
/// myButton.setOnClickListener(new View.OnClickListener() {
/// @Override
/// public void onClick(View v) {
//// dialog.dismiss();
// }
/// });
dialog.show();
}
});
}
}
Güncelleme:
Burada Customadapter bireysel ekleyerek onClickListners tarafından did it sadece birini ListView
kullanmalıdır kodu
class CustomListView extends ArrayAdapter {
public CustomListView(Context context, String[] resource) {
super(context,R.layout.custom_view , resource);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater MyInflater = LayoutInflater.from(getContext());
View CustomView = MyInflater.inflate(R.layout.custom_view, parent, false);
String SingleItem= (String) getItem(position);
TextView text =(TextView)CustomView.findViewById(R.id.Itemname);
ImageView Image= (ImageView)CustomView.findViewById(R.id.icon);
text.setText(SingleItem);
Image.setImageResource(R.drawable.myimage);
final Button Buybutton= (Button)CustomView.findViewById(R.id.BuyButton);
Buybutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), "Bought", Toast.LENGTH_SHORT).show();
}
});
Image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(),"Image",Toast.LENGTH_SHORT).show();
}
});
return CustomView;
}
}
Bunların her ikisinin de aynı anda kaymasını istiyorsanız, görüntüyü ve düğmeyi aynı liste görünümünde daha kolay olamaz mı? –
İlk liste görüntülendiğinde bazı başka işler yapmak istiyorum ... örneğin görüntüyü tıklatırsam tam ekran istenirse ve bu düğmeyi tıklatırsam başka şeyler yapması gerekir –
@SarmadAijaz elde edebilirsiniz İstediğiniz işlevselliği iki liste görünümüne gerek duymak için sadece bir liste görünümü kullanın – Dhiraj