我使用GridView适配器创建了一个布局,如下所示:https://gyazo.com/20990f2640d115e8751c386f51913142 如何添加这样的按钮,它也可以滚动?: https://gyazo.com/46806b05c52e963f146cc7f87f2017b1
片段中的我的适配器:
a = set([5, 6])
b = set([6, 7])
c = a & b # get the itersection
if len(c) == len(a) - 1:
return a | b # their union
我的片段XML:
package com.aaron.waller.tanzverbotsoundboard.mFragments;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import com.aaron.waller.tanzverbotsoundboard.MainActivity;
import com.aaron.waller.tanzverbotsoundboard.R;
/**
* Created by Oclemmy on 5/10/2016 for ProgrammingWizards Channel and http://www.Camposha.com.
*/
public class erstesFragment extends Fragment{
GridView myGridView;
public String[] items1 ={"alter schwede","Alter finne","was was was","ach schön","Du alte kacksau","Beatbox","Achjaa 1","Achjaa 2","Warum hast du eine Maske auf?"
,"boah 1","boah 2","Das Kackhuhn","Das ist doch wohl..."
,"Das ist ja unverschämt","das ist nicht wahr 1","das ist nicht wahr 2"
,"Das klappt ja super","eh","eh was","wie gemein","Engels-\nstimme","Englisch skills over 9000"
,"Freunde suche","Evil chicken","Pfui 1","Pfui 2","Gehirn-\naussetzer","Feierlaune","Gesangs-\neinlage 1"
,"Gesangs-\neinlage 2","Gesangs-\neinlage 3","was?","Miau","Halt die Fresse","hör auf","huaa","huch 1","huch 2","huiii","Ich bin noch ganz klein","ja geile scheiße","jaa"
,"Jo","kann man machen","Ihre Frau hat krebs","Komisches Geräusch 1","Komisches Geräusch 2","Komisches Geräusch 3","Komisches Geräusch 4","Komisches Geräusch 5","Komisches Geräusch 6","Komisches Geräusch 7"
,"Kuh 1","Kuh 2","Kuh 3","Definition von Kunstraum","Ladescreen 1","Ladescreen 2","Ladescreen 3","Ladescreen 4","Ladescreen 5","Ladescreen 6","Ladescreen 7","Ladescreen 8","Ladescreen 9"
,"Ledersofa aus Plastik","Mobbing spiel","Nachbar 1","Nachbar 2","Nachbar 3","Neiin 1","Neiin 2","Neiin 3","Neiin 4","Nein Nein Nein nein","niemals","ok","oke","oh man","Omi?","Omi bist dus?","Geschäfts-\nidee"
,"Der Pissnapf","Plastik-\nfliesen","Qualität","Dunkel wie im Rattenarsch","Räusperer","Rindenmulch","Die Scheere","wueah","schlipper","Schnauze!","Der Schwimmer","Soo 1"
,"soo 2","Spieglein Spieglein...","Sprachlos 1","Sprachlos 2","Stöhnen 1","Stöhnen 2","Stöhnen + Neiin","Das Treppenhaus","Tupperparty","und ähm 1","und ähm 2","Nur ein husten"
,"Wie geil ist das denn 1","Wie geil ist das denn 2"};
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView=inflater.inflate(R.layout.erstes_fragment,container,false);
myGridView = (GridView)rootView.findViewById(R.id.gridView1);
myGridView.setAdapter(new CustomGridAdapter(getActivity(), items1));
return rootView;
}
public class CustomGridAdapter extends BaseAdapter {
private Context context;
private String[] items;
LayoutInflater inflater;
public CustomGridAdapter(Context c, String[] items) {
this.context = c;
this.items = items;
inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return items.length;
}
@Override
public Object getItem(int position) {
return items[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.single_item, null);
}
Button button = (Button) convertView.findViewById(R.id.button);
button.setText(items[position]);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (context instanceof MainActivity) {
((MainActivity) context).itemClicked1(position);
}
}
});
return convertView;
}
}
}
答案 0 :(得分:0)
import pandas
df = pandas.read_csv("filepath")
query = list(df)
不支持列跨越。您必须改为使用GridView
和TableLayout
。