程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> C++求Fib數列

C++求Fib數列

編輯:關於C++

C++求Fib數列。本站提示廣大學習愛好者:(C++求Fib數列)文章只能為提供參考,不一定能成為您想要的結果。以下是C++求Fib數列正文


不曉得年夜家能否用過每天動人,關於它界面上的半通明Menu後果,筆者感到異常英俊。上面是每天動人半通明Menu的截圖,觀賞下吧:

       感到還不錯吧?那末若何完成這類半通明Menu後果呢?本文就重點評論辯論並給出這類Menu的詳細代碼完成進程。

       起首剖析下完成這類半通明Menu所需做的任務,並停止公道分化:

       1.  應用Shaper設置一個半通明圓角配景。

       2.  界說Menu結構,重要就GridView,把圖標都放在這個GridView。

       3.  Menu事宜, 經由過程PopupWindow或許AlertDialog或許通明Activity顯示到頁面便可。

       4.  按鈕的監聽事宜,實例中沒加。須要的話本身在Adapter裡加。

       比擬簡略,不多說了。

       半通明圓角配景xml:

XML/HTML代碼

<?xml version="1.0" encoding="UTF-8"?> 
 
<shape android:shape="rectangle">  
 
 <solid android:color="#b4000000" /> 
 
 <stroke android:width="2.0dip" android:color="#b4ffffff" android:dashWidth="3.0dip" android:dashGap="0.0dip" /> 
 
 <padding android:left="7.0dip" android:top="7.0dip" android:right="7.0dip" android:bottom="7.0dip" /> 
 
 <corners android:radius="8.0dip" /> 
 
</shape> 

        Menu結構:

XML/HTML代碼

<?xml version="1.0" encoding="UTF-8"?> 
 
<LinearLayout 
 
  android:orientation="vertical" 
 
  android:layout_width="wrap_content" 
 
  android:layout_height="fill_parent"> 
  
 
  <GridView android:gravity="center" 
 
    android:layout_gravity="center" 
 
    android:id="@+id/menuGridChange" 
    
    android:background="@drawable/menu_bg_frame" 
 
    android:padding="5.0dip" 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="wrap_content" 
 
    android:horizontalSpacing="10.0dip" 
 
    android:verticalSpacing="3.0dip" 
 
    android:stretchMode="columnWidth" 
 
    android:columnWidth="60.0dip" 
 
    android:numColumns="auto_fit"/> 
 
     
</LinearLayout> 

       重要類:

Java代碼

package com.yfz; 
 
 
import android.app.Activity; 
import android.app.AlertDialog; 
import android.app.AlertDialog.Builder; 
import android.content.Context; 
import android.graphics.drawable.BitmapDrawable; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.ContextMenu; 
import android.view.Gravity; 
import android.view.LayoutInflater; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.view.ViewGroup; 
import android.view.ContextMenu.ContextMenuInfo; 
import android.widget.BaseAdapter; 
import android.widget.GridView; 
import android.widget.ImageView; 
import android.widget.LinearLayout; 
import android.widget.PopupWindow; 
import android.widget.TextView; 
import android.widget.LinearLayout.LayoutParams; 
 
public class MenuTest extends Activity {   
 
  private String TAG = this.getClass().getSimpleName();   
 
  private int[] resArray = new int[] { 
    R.drawable.icon_menu_addto, R.drawable.icon_menu_audioinfo, 
    R.drawable.icon_menu_findlrc, R.drawable.icon_menu_scan 
  };   
 
  private String[] title = new String[]{ 
    "添加歌曲", "歌曲信息", "查找歌詞", "搜刮歌詞" 
  };   
 
  private static boolean show_flag = false;   
  private PopupWindow pw = null;   
 
  /** Called when the activity is first created. */ 
  @Override 
  public void onCreate(Bundle savedInstanceState) { 
   super.onCreate(savedInstanceState); 
   setContentView(R.layout.main); 
  } 
 
  @Override 
 
  public boolean onCreateOptionsMenu(Menu menu) { 
    Log.e(TAG, "------ onCreateOptionsMenu ------"); 
    //用AlertDialog彈出menu 
 
//    View view = LayoutInflater.from(this).inflate(R.layout.menu, null); 
 
//    GridView grid1 = (GridView)view.findViewById(R.id.menuGridChange); 
 
//    grid1.setAdapter(new ImageAdapter(this)); 
 
//    Builder build = new AlertDialog.Builder(this); 
 
//    build.setView(view); 
 
//    build.show(); 
     
    LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);   
 
    View view = inflater.inflate(R.layout.menu, null); 
 
    GridView grid1 = (GridView)view.findViewById(R.id.menuGridChange); 
 
    grid1.setAdapter(new ImageAdapter(this));     
 
    //用Popupwindow彈出menu 
    pw = new PopupWindow(view,LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);     
 
    //NND, 第一個參數, 必需找個View 
    pw.showAtLocation(findViewById(R.id.tv), Gravity.CENTER, 0, 300);     
 
    return true; 
  } 
 
  @Override 
 
  public boolean onOptionsItemSelected(MenuItem item) { 
    return super.onOptionsItemSelected(item); 
  } 
 
  public class ImageAdapter extends BaseAdapter {     
    private Context context;     
 
    public ImageAdapter(Context context) { 
      this.context = context; 
    }     
 
    @Override 
    public int getCount() { 
      return resArray.length; 
    } 
 
    @Override 
    public Object getItem(int arg0) { 
      return resArray[arg0]; 
    } 
 
    @Override 
    public long getItemId(int arg0) { 
      return arg0; 
    } 
 
    @Override 
    public View getView(int arg0, View arg1, ViewGroup arg2) { 
      LinearLayout linear = new LinearLayout(context); 
 
      LinearLayout.LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
 
      linear.setOrientation(LinearLayout.VERTICAL);       
 
      ImageView iv = new ImageView(context); 
 
      iv.setImageBitmap(((BitmapDrawable)context.getResources().getDrawable(resArray[arg0])).getBitmap()); 
 
      LinearLayout.LayoutParams params2 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
 
      params2.gravity=Gravity.CENTER; 
 
      linear.addView(iv, params2);       
 
      TextView tv = new TextView(context); 
 
      tv.setText(title[arg0]); 
 
      LinearLayout.LayoutParams params3 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
 
      params3.gravity=Gravity.CENTER;       
 
      linear.addView(tv, params3);       
      return linear; 
    } 
  } 
} 

        到此,年夜家是否是認為半通明Menu後果也是比擬好完成的呢?可以依據本身的須要對此實例停止修正以求更雅觀好用。

        以上就是對Android Menu 半通明後果的完成,後續持續彌補相干材料感謝年夜家對本站的支撐!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved