- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
当我尝试创建我的 Item 类的新实例时,我收到有关“没有可访问类型的封闭实例”的错误。我不确定那是什么意思。所以我不知道从这里去哪里。请帮忙。提前谢谢大家
public static class GreetFrag extends Fragment {
public static final String ARG_OBJECT = "object";
private List<RowItem> rowItems;
private List<Item> newList;
PinnedSectionListActivity pActivity = new PinnedSectionListActivity();
ListView lv;
ListView newLv;
Item item;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_greetfrag_swipeview, container, false);
//lv = (ListView) rootView.findViewById(R.id.myList);
newLv = (ListView) rootView.findViewById(R.id.newList);
//rowItems = new ArrayList<RowItem>();
newList = new ArrayList<MenuActivity.GreetFrag.PinnedSectionListActivity.Item>();
String[] english = {"Hi (to same age or younger)",
"Yo!", "Hey!", "Good to see ya.","Hello?","Who dis?","What’s up?","How ya been?","Yeah, I’m good!","Good!","So-so.","Sucky.",
"Whatcha been up to?","Long time no see!","It’s been a while.","You’re still alive?","You need to lose some weight!",
"Your face has gotten chubbier!","Your mom has gotten chubbier!","Goodbye","Goodbye (general use)","Goodbye (to a person staying)",
"Goodbye (to a person leaving)","Goodbye (when both parties are parting)","Bye bye","See ya!","Later!","I’m out.","Be careful!",
"Good morning(formal)", "G'morning!", "Sleep well?", "It's a beautiful evening!", "Good evening!(formal)", "Evenin", "Sweet dreams!",
"Dream about me!", "Sorry!(informal)", "FOrgive me!", "Oops!", "My bad!", "No worries", "It's all good", "No problem", "Forget aboutit",
"Can you please do me a favor?", "Please, accept my heart!", "Excuse me", "Move our of my way!", "Be careful!", "My name is Michael",
"I am from America", "I have yello fever", "I am 18 years ola dn full of testosterone", "I like hairy girls",
"Can you setme up on a blind date with one of your hottie frineds?", "Nice to meet you", "What's your name?",
"Have we met before?", "Do you have the time?", "How old are you?"};
String[] roman = {"Annyeong",
"Ya!", "Imma!", "Banga banga","Yeoboseyo?","Nuguseyo?","Wannya?","Jal jinaeni?","Eung, jal jinae!","Joa!","Geunyang geurae.","Guryeo.",
"Mohago sarannya?","Oretmaniyeyo!","Olman!","Saraisseonnya?","Sal jom bbaeyagetda!",
"Eolguli tongtonghae!", "Neone eomma saljom jjisyeosseo!","Jal jinae~","Annyeong~","Jal isseo~","Tto boja!",
"Jal ga~","Jal jinae~","Bai bai","Najungebwa!","Na ganda.","Josimhae!", "Annyeonghi jumusyeoseoyo","Joeun achim!",
"Jal Jasseo?","Joeun bam!", "Anneonghi jumuseyo", "jalja", "Joeun kkumkkwo!", "Nae kkumkkwo!", "Mian!",
"Yongseohaejwo!", "At!", "Silsu!", "Geokjeonghajima", "Da gwaenchana", "Munjae eopsseo", "Ijeobeoryeo",
"Budi butak jom deureojullae?", "Jebal je mamaeul badajuseyo!", "Sillyehapnida/Jamsimanyo", "Bikyeo!",
"Josim!", "Je ireumeun Michael ipsida", "Jeoneun migukeseo wasseupnida", "Jeoneun dongyanginman joahapnida",
"Jeoneun yeolyeodeolssaligo himi neomchipnida", "Jeoneun teol maneun yeojaga jossepnida",
"Jal sang-gin chingurang na sogaeting sikyejo?", "Mannaseo ban-gapseupnida", "Ireumi mwoyeyo?",
"Uri mannanjeok itnayo?", "Jgeum myeossiyeyo?", "Naiga eotteoke dwae?"};
String[] hangul = {"안녕",
"야!", "임마!", "방가 방가","여보세요?","누구세요?","왔냐?","잘 지내니?","응, 잘 지내!","좋아!","그냥 그래.","구려.",
"뭐하고 살았냐?","오랫만이예요!","올만!","살아있었냐?","살 좀 빼야겠다!",
"얼굴이 통통해!","너네 엄마 살좀 찌셨어!","잘 지내~","안녕~","잘 있어~",
"잘 가~","잘 지내~","바이 바이","또 보자!","나중에봐!","나 간다.","조심해!",
"안녕히 주무셨어요", "좋은 아침!", "잘 잤어?", "좋은 밤!", "안녕히 주무세요",
"잘자", "좋은 꿈꿔!", "내 꿈꿔!", "미안!", "용서해줘!", "앗!", "실수!", "걱정하지마",
"다 괜찮아","문제없어", "잊어버려", "부디 부탁 좀 들어줄래?", "제발 제 맘을 받아주세요!",
"실례합니다/잠시만요", "비켜!", "조심!", "제 이름은 마이클입니다", "저는 미국에서 왔습니다",
"저는 동양인만 좋아합니다", "저는 열여덟살이고 힘이 넘칩니다", "저는 털 많은 여자가 좋습니다",
"잘 생긴 친구랑 나 소개팅 시켜줘?", "만나서 반갑습니다", "이름이 뭐예요?", "우리 만난적 있나요?",
"지금 몇시예요?", "나이가 어떻게 돼?"};
//Populate the List
for (int i = 0; i < english.length; i++) {
item = new Item(english[i], hangul[i], roman[i], 1, "test");
newList.add(item);
}
// Set the adapter on the ListView
LazyAdapter adapter = new LazyAdapter(getActivity(), R.layout.view_lessons, rowItems);
//lv.setAdapter(adapter);
/**
lv.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
**/
return rootView;
}
public class PinnedSectionListActivity extends ListActivity implements OnClickListener {
public class CustomAdapter extends ArrayAdapter<Item> implements PinnedSectionListAdapter {
Context context;
List <Item> items;
private final int[] COLORS = new int[] {
R.color.green_light,
R.color.orange_light,
R.color.blue_light,
R.color.red_light };
class ViewHolder {
int sectionPosition;
int listPosition;
TextView english;
TextView romanization;
TextView hangul;
RelativeLayout card;
}
public CustomAdapter(Context context, int resourceId, List<Item> items) {
super(context, resourceId, items);
this.context = context;
}
public CustomAdapter(Context context, int resource, int textViewResourceId) {
super(context, resource, textViewResourceId);
final int sectionsNumber = 'Z' - 'A' + 1;
prepareSections(sectionsNumber);
int sectionPosition = 0, listPosition = 0;
for (int i=0; i< sectionsNumber; i++) {
String title = null;
final String []country = {
"Korean", "Japanese", "Chinese", "Cambodian", "Loas", "Taiwamese"
};
final String [] CATEGORY = {
"Language",
"sports",
"love",
"luxury",
"vacation",
"games",
"home",
"travel",
"electronics",
"movies",
};
switch (('A' + i)) {
case ('A' + 0):
title = country[0];
break;
case ('A' + 1):
title = country[1];
break;
case ('A' + 2):
title = country[2];
break;
case ('A' + 3):
title = country[3];
break;
case ('A' + 4):
title = country[4];
break;
case ('A' + 5):
title = country[5];
break;
default:
break;
}
//Create a new Item class with section header and Name
Item section = new Item(Item.SECTION, title + " " + i);
//Item section = new Item(Item.SECTION, String.valueOf((char)('A' + i)));
section.sectionPosition = sectionPosition;
section.listPosition = listPosition++;
onSectionAdded(section, sectionPosition);
add(section);
final int itemsNumber = CATEGORY.length;
//(int) Math.abs((Math.cos(2f*Math.PI/3f * sectionsNumber / (i+1f)) * 25f));
// For loop to iterate the exact number of itemNumber
for (int j = 0;j < CATEGORY.length;j++) {
//Item item = new Item(Item.ITEM, section.text.toUpperCase(Locale.KOREA) + " - " + j);
Item item = new Item(Item.ITEM, CATEGORY[j]);
item.sectionPosition = sectionPosition;
item.listPosition = listPosition++;
add(item);
}
sectionPosition++;
}
}
protected void prepareSections(int sectionsNumber) { }
protected void onSectionAdded(Item section, int sectionPosition) { }
@Override public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder view = null;
Item item = getItem(position);
LayoutInflater mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.view_lessons, null);
view.card = (RelativeLayout) convertView.findViewById(R.id.card);
view.romanization = (TextView)convertView.findViewById(R.id.romanization);
view.english = (TextView)convertView.findViewById(R.id.english_translation);
view.hangul = (TextView)convertView.findViewById(R.id.hangul);
convertView.setTag(view);
} else {
view = (ViewHolder)convertView.getTag();
view.romanization.setText(item.getRomanization());
view.english.setText(item.getEnglish());
view.hangul.setText(item.getHangul());
Animation animation = AnimationUtils.loadAnimation(context, R.anim.card_animation);
view.card.startAnimation(animation);
if (item.type == Item.SECTION) {
//view.setOnClickListener(PinnedSectionListActivity.this);
view.english.setBackgroundColor(parent.getResources().getColor(COLORS[item.sectionPosition % COLORS.length]));
}
}
return convertView;
}
@Override public int getViewTypeCount() {
return 2;
}
@Override public int getItemViewType(int position) {
return getItem(position).type;
}
@Override
public boolean isItemViewTypePinned(int viewType) {
return viewType == Item.SECTION;
}
}
class Item {
private String english;
private String hangul;
private String romanization;
public static final int ITEM = 0;
public static final int SECTION = 1;
public final int type;
public final String text;
public int sectionPosition;
public int listPosition;
public Item(String english, String hangul, String romanization, int type, String text) {
super();
this.type = type;
this.text = text;
this.english = english;
this.hangul = hangul;
this.romanization = romanization;
}
public String getEnglish() {
return english;
}
public void setEnglish(String english) {
this.english = english;
}
public String getHangul() {
return hangul;
}
public void setHangul(String hangul) {
this.hangul = hangul;
}
public String getRomanization() {
return romanization;
}
public void setRomanization(String romanization) {
this.romanization = romanization;
}
public Item(int type, String text) {
this.type = type;
this.text = text;
}
@Override public String toString() {
return text;
}
}
public class FastScrollAdapter extends CustomAdapter implements SectionIndexer {
private Item[] sections;
public FastScrollAdapter(Context context, int resource, int textViewResourceId) {
super(context, resource, textViewResourceId);
}
@Override protected void prepareSections(int sectionsNumber) {
sections = new Item[sectionsNumber];
}
@Override protected void onSectionAdded(Item section, int sectionPosition) {
sections[sectionPosition] = section;
}
@Override public Item[] getSections() {
return sections;
}
@Override public int getPositionForSection(int section) {
if (section >= sections.length) {
section = sections.length - 1;
}
return sections[section].listPosition;
}
@Override public int getSectionForPosition(int position) {
if (position >= getCount()) {
position = getCount() - 1;
}
return getItem(position).sectionPosition;
}
}
private boolean hasHeaderAndFooter;
private boolean isFastScroll;
private boolean addPadding;
private boolean isShadowVisible = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState != null) {
isFastScroll = savedInstanceState.getBoolean("isFastScroll");
addPadding = savedInstanceState.getBoolean("addPadding");
isShadowVisible = savedInstanceState.getBoolean("isShadowVisible");
hasHeaderAndFooter = savedInstanceState.getBoolean("hasHeaderAndFooter");
}
initializeHeaderAndFooter();
initializeAdapter();
initializePadding();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("isFastScroll", isFastScroll);
outState.putBoolean("addPadding", addPadding);
outState.putBoolean("isShadowVisible", isShadowVisible);
outState.putBoolean("hasHeaderAndFooter", hasHeaderAndFooter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
menu.getItem(0).setChecked(isFastScroll);
menu.getItem(1).setChecked(addPadding);
menu.getItem(2).setChecked(isShadowVisible);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_fastscroll:
isFastScroll = !isFastScroll;
item.setChecked(isFastScroll);
initializeAdapter();
break;
case R.id.action_addpadding:
addPadding = !addPadding;
item.setChecked(addPadding);
initializePadding();
break;
case R.id.action_showShadow:
isShadowVisible = !isShadowVisible;
item.setChecked(isShadowVisible);
((PinnedSectionListView)getListView()).setShadowVisible(isShadowVisible);
break;
case R.id.action_showHeaderAndFooter:
hasHeaderAndFooter = !hasHeaderAndFooter;
item.setChecked(hasHeaderAndFooter);
initializeHeaderAndFooter();
break;
}
return true;
}
private void initializePadding() {
float density = getResources().getDisplayMetrics().density;
int padding = addPadding ? (int) (16 * density) : 0;
getListView().setPadding(padding, padding, padding, padding);
}
private void initializeHeaderAndFooter() {
setListAdapter(null);
if (hasHeaderAndFooter) {
ListView list = getListView();
LayoutInflater inflater = LayoutInflater.from(this);
TextView header1 = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, list, false);
header1.setText("First header");
list.addHeaderView(header1);
TextView header2 = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, list, false);
header2.setText("Second header");
list.addHeaderView(header2);
TextView footer = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, list, false);
footer.setText("Single footer");
list.addFooterView(footer);
}
initializeAdapter();
}
@SuppressLint("NewApi")
private void initializeAdapter() {
getListView().setFastScrollEnabled(isFastScroll);
if (isFastScroll) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getListView().setFastScrollAlwaysVisible(true);
}
setListAdapter(new FastScrollAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1));
} else {
setListAdapter(new CustomAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1));
}
}
@Override
public void onClick(View v) {
Toast.makeText(this, "Item: " + v.getTag() , Toast.LENGTH_SHORT).show();
}
}
}
Here is the whole fragment.
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!