1首先 ExpandableListView elistview;
十載的西工網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)整合營(yíng)銷(xiāo)推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整西工建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“西工網(wǎng)站設(shè)計(jì)”,“西工網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
elistview.setGroupIndicator(null);//將控件默認(rèn)的左邊箭頭去掉,
2在 自定義的繼承自BaseExpandableListAdapter的adapter中有一個(gè)方法
/**
* 父類view
*/
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
Log.i("zhaoxiong","parent view");
LinearLayout parentLayout=(LinearLayout) View.inflate(context, R.layout.wowocoupons_parent_item, null);
TextView parentTextView=(TextView) parentLayout.findViewById(R.id.parentitem);
parentTextView.setText(parentlist.get(groupPosition));
ImageView parentImageViw=(ImageView) parentLayout.findViewById(R.id.arrow);
//判斷isExpanded就可以控制是按下還是關(guān)閉,同時(shí)更換圖片
應(yīng)該是錯(cuò)誤的,java代碼沒(méi)有右箭頭的,除非是在注釋行里出現(xiàn)的。
按alt + 方向鍵的左箭頭 是返回到f3之前的代碼
按alt+ 方向鍵的右箭頭 是前進(jìn)到上一步的代碼
”僅有一個(gè)焦點(diǎn)組件能夠接收KeyEvent。要使一個(gè)組件成為焦點(diǎn)組件,需要將屬性isFocusable設(shè)置為true。“
-----------------------------------------
Ps:小細(xì)節(jié),上下弄反了。y軸向下遞增。
-----------------------------------------------------
修改方法之一見(jiàn)注釋
package?baidu;
import?java.awt.event.*;
import?java.awt.*;
import?javax.swing.*;
public?class?MyGraphics3?extends?JFrame{????
public?static?void?main(String[]?args){
new?MyGraphics3(100,100);
}
public?MyGraphics3(int?x,int?y){
MGraphics3?mg?=?new?MGraphics3(x,?y);
mg.setFocusable(true);???????//設(shè)置為焦點(diǎn)組件!?。?/p>
add(mg);
//add(new?MGraphics3(x,y));
setVisible(true);
setLocation(500,350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
}
}
class?MGraphics3?extends?JPanel{
private?int?x,y;
public?MGraphics3(int?x,int?y){
this.x?=?x;
this.y?=?y;
addKeyListener(new?Monitor3());
}
public?void?paint(Graphics?g){
super.paint(g);
g.setColor(Color.BLUE);
g.fillOval(x,y,10,10);
}
public?void?move(int?a,int?b){
x?+=?a;
y?+=?b;
repaint();
}
class?Monitor3?extends?KeyAdapter{
public?void?keyPressed(KeyEvent?e){
if(e.getKeyCode()?==?KeyEvent.VK_UP){
move(0,5);
}else?if(e.getKeyCode()?==?KeyEvent.VK_DOWN){
move(0,-5);
}else?if(e.getKeyCode()?==?KeyEvent.VK_RIGHT){
move(5,0);
}else?if(e.getKeyCode()?==?KeyEvent.VK_LEFT){
move(-5,0);
}else{
System.out.println("ERROR!!!");
move(0,0);
}
}
}
}