顯示具有 android 標籤的文章。 顯示所有文章
顯示具有 android 標籤的文章。 顯示所有文章

選取手機裡的相片

參考第一種:手機裡的所有圖片Intent mediaChooser = new Intent(Intent.ACTION_GET_CONTENT);mediaChooser.setType("video/*, images/*");startActivityForResult(mediaChooser, RESULT_LOAD_IMAGE);

第二種:只有在相片集裡的Intent mediaChooser = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);mediaChooser.setType("image/* video/*");startActivityForResult(mediaChooser, RESULT_LOAD_IMAGE);

app直接執行不跳layout畫面

<activity
           
            android:theme="@android:style/Theme.Dialog">

</activity>

ACTION_CALL and ACTION_DIAL

There are two intents to call/start calling: ACTION_CALL and ACTION_DIAL. ACTION_DIAL will only open the dialer with the number filled in, but allows the user to actually call or reject the call. ACTION_CALL will immediately call the number and requires an extra permission. So make sure you have the permission

<uses-permission android:name="android.permission.CALL_PHONE" />

Snippets in Eclipse

  • 1. Installing Snippets inEclipse (Juno)This tutorial shows you how to install the Eclipse Snippet plugin if it’s notavailable. Snippets are part of the Web Developer Tools, specifically the WSTCommon UI. These tools don’t come with all packaged versions of Eclipse. © 2005-2013 New Life in IT Pty Ltd - Visit learn.theartofjoomla.com to learn more about Joomla!
  • 2. From the menu bar, select Help ➞ Install New Software...
  • 3. Enter “http://download.eclipse.org/releases/juno” into the “Work with:” text box.Scroll down, find and expand the “Web, XML ... Development” entry.
  • 4. Scroll down and check the “Eclipse Web Developer Tools” item.Then, click the “Next” button.
  • 5. On the next page, click the “Next” button again.
  • 6. Activate the “I accept the terms ...” radio button.Then, click the “Finish” button.
  • 7. Let Eclipse do its thing, then restart Eclipse when it asks you to.
  • 8. From the menu bar, choose Window ➞ Show View ➞ Other...
  • 9. Start typing “snip” in the filter box.Then, select “Snippets” and then click the “OK” button.
  • 10. The snippets view will probably appear in the bottom pane (note, yours will probably be empty).



Textview 提示文字

轉貼

Example source code for Android development. How set gray text to EditText when EditText is blank.
Hint text to display when the text is empty.
In layout/main.xml insert to EditText row Attribute Name android:hint=”Some text”
 
<EditText
        android:id="@+id/myEdit" 
 android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:hint="Some text"
 android:singleLine="true"
</EditText>
Programatically you can use method setHint:
 
// setHint(CharSequence hint) example
(EditText)findViewById(R.id.myEdit).setHint("My text");
// or int resId as method setHint(int resId) 
EditText myEdit = findViewById(R.id.myEdit);
myEdit.setHint(R.string.app_name);

輸入變數產生checkbox

package com.android.dinolayout;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {


@Override

public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);

   ScrollView sv = new ScrollView(this);
   final LinearLayout ll = new LinearLayout(this);
   ll.setOrientation(LinearLayout.VERTICAL);
   sv.addView(ll);
 

   TextView tv = new TextView(this);
   tv.setText("動態產生checkbox範例");
   ll.addView(tv);

   final EditText et = new EditText(this);
   et.setText("3");
   ll.addView(et);
 
 
   Button b = new Button(this);
   b.setText("按下以自動產生checkbox");
   ll.addView(b);

   //String ddd = String.valueOf(ll.getChildCount());
    //Toast.makeText(et.getContext(), ddd, Toast.LENGTH_LONG).show();

   b.setOnClickListener(new OnClickListener() {



    int lare = 0;
       @Override
       public void onClick(View v) {
       
  //確認該view存在,才會執行.    
       
        //String ddd = String.valueOf(ll.getChildCount());
        //String xxx = String.valueOf(ll.getChildAt(0).toString());
        //Toast.makeText(v.getContext(), ddd, Toast.LENGTH_LONG).show();
       
        if (ll.getChildCount() != 3) {
        //String ccc = "刪除";
        //Toast.makeText(v.getContext(), ccc, Toast.LENGTH_LONG).show();
        ll.removeViews(3, lare);
       
        }
       
        int length = Integer.parseInt(et.getText().toString()) ;
        for(int i = 1 ; i <= length ; i++) {
               CheckBox cb = new CheckBox(getApplicationContext());
               cb.setText("I'm dynamic!"+ i);
               ll.addView(cb);
               lare = i;
       }


       }
   });


   this.setContentView(sv);

  }
}

非看不可

【超好用】貼圖快速裁切,極速上架。

輕鬆自製 LINE 貼圖!免安裝的超強網頁版「簡單的圖片工具」推薦 裁切、去背、標註一氣呵成,專為貼圖創作者打造的高效神器 很多創作者在製作 LINE 貼圖時,最常遇到的痛點就是: 尺...