国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網 會員登陸 & 注冊

Android QPython3 擴展:圖片命令菜單

2021-01-02 22:21 作者:乘著船  | 我要投稿

#需要QPythonSupport基礎窗口??https://www.bilibili.com/read/cv9100444


QPythonSupport/app/src/main/AndroidManifest.xml】添加


? <activity

? ? ? ? ? ? android:label="圖片命令列表"

? ? ? ? ? ? android:name=".ImageCmd"

? ?android:theme="@android:style/Theme.NoTitleBar" >

? ?<intent-filter>

? ? ? ? ? ? ? ? <action android:name="android.intent.action.VIEW" />

? ? ? ? ? ? </intent-filter>

? ? ? ? </activity>


QPythonSupport/app/src/main/res/layout/imageCmd.xml


<LinearLayout

?android:layout_width="fill_parent"

?android:layout_height="fill_parent"

?android:background="#af7f3f"

?android:orientation="vertical"

?xmlns:android="http://schemas.android.com/apk/res/android">

? ? <ScrollView

? ? ? ? android:layout_width="fill_parent"

? ? ? ? android:layout_height="50dp"

? android:layout_weight="1" >?

?<TextView

? android:id="@+id/ImageCmdTitle"

? android:layout_width="fill_parent"

? android:layout_height="wrap_content"

? android:textSize="25dp"

? android:background="#3faf7f"

? android:textColor="#ffffff"

? android:textStyle="bold"

? android:gravity="center"

?/>

? ? </ScrollView>

? ? <ListView

? ? ? ? android:id="@+id/ImageCmdList"

? ? ? ? android:layout_width="match_parent"

? ? ? ? android:layout_height="wrap_content"

? ? ? ? android:layout_weight="20"

?/>

?<Button

? android:layout_width="fill_parent"

? android:layout_height="50dp"

? android:id="@+id/ImageCmdCancel"

? android:textSize="25dp"

? android:background="#7f7fff"

? android:textColor="#ffffff"

? android:layout_weight="1"

? android:gravity="center"/>

</LinearLayout>


QPythonSupport/app/src/main/res/layout/imageCmdView.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

? ? android:layout_width="fill_parent"

? ? android:layout_height="fill_parent"

? ? android:orientation="vertical">

? ??

?<ImageView

? android:id="@+id/ImageCmdViewImage"

? android:layout_width="fill_parent"

? android:layout_height="wrap_content"

? android:adjustViewBounds="true"

? android:scaleType="fitXY"

?/>


? ? <TextView

? android:id="@+id/ImageCmdViewText"

? android:layout_width="fill_parent"

? android:layout_height="wrap_content"

? android:textSize="25dp"

? android:minHeight="50dp"

? android:gravity="center_vertical"

? android:textColor="#ffffff"

?/>


</LinearLayout>


QPythonSupport/app/src/main/java/czc/qpython/support/ImageCmd.java


package czc.qpython.support;


import android.app.*;

import android.content.*;

import android.os.*;

import android.view.*;

import android.view.View.*;

import android.widget.*;

import android.widget.AdapterView.*;

import java.io.*;


import android.view.View.OnClickListener;

import android.net.*;


public class ImageCmd extends Activity

{

?String[] items;

?String[] images;


? ? /** Called when the activity is first created. */

? ? @Override

? ? public void onCreate(Bundle savedInstanceState)

?{

? Main.requestPermissions(this);

? ? ? ? super.onCreate(savedInstanceState);

? ? ? ? // Set main.xml as user interface layout

? ? ? ? setContentView(R.layout.imageCmd);

??

? Intent intent=getIntent();

? String title=intent.getStringExtra("title");

? items=intent.getStringArrayExtra("items");

? try{

? images=intent.getStringArrayExtra("images");

? } catch(Exception E) {}

? String cancel=intent.getStringExtra("cancel");


? ? ? ? TextView Title=(TextView) findViewById(R.id.ImageCmdTitle);

? Title.setText(title);

??

? ListAdapter adapter = new ImageCmdAdapter(this, items);

? ListView listView = (ListView) findViewById(R.id.ImageCmdList);

? listView.setAdapter(adapter);

??

? listView.setOnItemClickListener(new OnItemClickListener() {

? ?@Override

? ?public void onItemClick(AdapterView<?> l, View v, int position, long id)

? ?{

? ? ? ?Intent intentR=new Intent();

? ? intentR.putExtra("result",position);

? ? ImageCmd.this.setResult(RESULT_OK,intentR);

? ? ImageCmd.this.finish();

? ?}

? });

? ?

? Button Cancel=(Button) findViewById(R.id.ImageCmdCancel);

? Cancel.setText(cancel);

? Cancel.setOnClickListener(new OnClickListener() {

? ?public void onClick(View p)

? ?{

? ? ImageCmd.this.finish();

? ?}

? });

?}


?class ImageCmdAdapter extends ArrayAdapter<String>

?{

? public ImageCmdAdapter(Context context, String[] values)?

? {

? ?super(context, R.layout.imageCmdView, values);

? }


? @Override

? public View getView(int position, View convertView, ViewGroup parent)

? {

? ?LayoutInflater inflater = LayoutInflater.from(getContext());

? ?View view = inflater.inflate(R.layout.imageCmdView, parent, false);


? ?TextView Text = (TextView) view.findViewById(R.id.ImageCmdViewText);

? ?Text.setText(items[position]);


? ?ImageView Image = (ImageView) view.findViewById(R.id.ImageCmdViewImage);

? ?try{

? ?String img=images[position];

? ?Image.setImageURI(Uri.fromFile(new File(img)));

? ?} catch(Exception E){}


? ?return view;

? }

?}


}


QPythonSupport/__init__.py】添加


def ImageCmd(title='標題',items=('項目0',),images=(),cancel='取消'):

? ? r=rsla('startActivityForResult','android.intent.action.VIEW',None,None,{'title':title,'items':items,'images':images,'cancel':cancel},'czc.qpython.support','czc.qpython.support.ImageCmd')

? ? if r:

? ? ? ? return r['extras']['result']

? ? else:

? ? ? ? return r


QPythonSupport/說明.txt】添加


? ImageCmd(title='標題',items=('項目0',),images=(),cancel='取消')

? 圖片命令菜單(標題文本,各項目文本(項目1,項目2,……),各項目圖片路徑(圖片1,圖片2,……),取消按鈕文本)

? ? 各項目文本items只能是tuple或list類型的str數(shù)組,且至少有一個項目;

? ? 各項目圖片路徑images只能是tuple或list類型的有效路徑str數(shù)組;

? ? 部分項目無圖片時,images可以部分項目為空str("");

? ? 全部項目無圖片時,images可以為空白tuple或空白list;

? ? 當images項目數(shù)量<items項目數(shù)量時,items剩余項目沒有圖片;

? ? 當images項目數(shù)量>items項目數(shù)量時,多余圖片會被忽略。


舉例:

from QPythonSupport import *
import os
A='/sdcard/Pictures/taobao/'
B=os.listdir(A)
C=list(B)
for d in range(len(C)):C[d]=A+C[d]
ImageCmd('淘寶圖片',B,C)

from QPythonSupport import *
import os
A='/sdcard/Pictures/taobao/'
B=os.listdir(A)
ImageCmd('淘寶圖片',B)

點擊第N個圖片/文字項,返回(N-1),

點擊“取消”,返回None。

視頻:https://www.bilibili.com/video/BV1Ty4y1U7cp


作者:乘著船@Bilibili

更多文章+下載鏈接:https://www.bilibili.com/read/readlist/rl321663


Android QPython3 擴展:圖片命令菜單的評論 (共 條)

分享到微博請遵守國家法律
光泽县| 剑河县| 穆棱市| 桂林市| 临高县| 宾阳县| 灌阳县| 诸城市| 威宁| 庄浪县| 齐齐哈尔市| 淮滨县| 河池市| 商都县| 齐齐哈尔市| 自治县| 湾仔区| 犍为县| 临沧市| 富平县| 互助| 大竹县| 娄底市| 长沙市| 黄浦区| 洪湖市| 体育| 苗栗市| 德格县| 南充市| 乐安县| 哈尔滨市| 宜州市| 淳安县| 邵东县| 雅江县| 招远市| 阿拉善左旗| 漠河县| 鄂伦春自治旗| 酒泉市|