當前位置:首頁 » 安卓系統 » android文字加圖片不顯示

android文字加圖片不顯示

發布時間: 2022-05-10 21:34:10

A. android開發 為什麼圖片無法顯示,源代碼如下

你可以講網路圖片獲取後存放到本地文件夾 然後獲取該文件的路徑 進行讀取
String sdpath="/sdcard/file/";

String path="/sdcard/file/"+圖片名字+".png";

BitmapFactory.Options opts = new BitmapFactory.Options();

opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, opts);

opts.inSampleSize = computeSampleSize(opts, -1, 240*240);

opts.inJustDecodeBounds = false;

Bitmap bm = BitmapFactory.decodeFile(path, opts);
appItem.mAppIcon.setImageBitmap(bm);

截取的部分代碼資料 可以借鑒下下...

B. Android XML添加了圖片,運行的時候不顯示

可能是放圖片的文件夾下沒有圖片,可能是沒有引入xml,可能是程序報錯了!圖片格式要是Png的
參考:http://jingyan..com/article/27fa7326db6bbd46f8271fae.html

C. 百度貼吧android客戶端圖片顯示不出來,怎麼辦

建議進行以下操作:
1.檢查手機網路連接是否穩定,建議更換無線網路嘗試。
2.更新軟體版本嘗試。
3.點擊手機應用程序-設定-應用程序管理器-已下載-選擇出現問題的應用-清除數據
4.將數據備份(聯系人,簡訊,圖片等),恢復出廠設置重新安裝嘗試
5.更新下手機系統版本。

D. android 怎麼點擊圖片顯示文字說明,再點擊消失了

添加圖片點擊事件,在點擊之後實現布局上的文字的顯示和消失,這個布局可以用frameLayout來實現,將上層的文字啥的先不顯示就行了

E. 安卓系統加進去的圖片不顯示

重啟一下試試,可能是媒體沒有掃描到。不然就是你圖片文件夾屬性設置有問題

F. android simpleadapter不顯示圖片

樓主不覺得自定義adapter更好用么?simpleadapter貌似不能添加圖片的。我這里給你一個簡單自定義適配器的代碼吧。
//2.適配器
BaseAdapter adapter = new BaseAdapter() {

@Override
public View getView(int position, View convertView, ViewGroup parent) {
Person person = (Person) getItem(position);
Context context = List1Activity.this;

LinearLayout layout = new LinearLayout(context);
layout.setTag(person);
layout.setOrientation(LinearLayout.HORIZONTAL);

//按照自己的意願去綁定數據
TextView view1 = new TextView(context);
view1.setText(person.getName());
view1.setBackgroundColor(Color.argb(100, 0, 0, 255));
view1.setTextColor(Color.RED);

TextView view2 = new TextView(context);
view2.setText("$" + person.getMoney());
view2.setBackgroundColor(Color.argb(100, 0, 255, 0));
view2.setTextColor(Color.BLUE);

//圖片
ImageView view3 = new ImageView(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
30, LayoutParams.MATCH_PARENT);
view3.setLayoutParams(params);
view3.setScaleType(ScaleType.FIT_CENTER);
if (person.isSex()) {
view3.setImageResource(R.drawable.girl);
} else {
view3.setImageResource(R.drawable.boy);
}

layout.addView(view1);
layout.addView(view2);
layout.addView(view3);

return layout;
}

@Override
public long getItemId(int position) {
return 0;
}

@Override
public Object getItem(int position) {
return list.get(position);
}

@Override
public int getCount() {
return list.size();
}
};

// 3.界面組件
lstPerson.setAdapter(adapter);

G. android studio文字輸入框加入圖片功能

1、打開androidstudio,將想要插入的圖片,復制一下,可以右擊選擇復制。
2、接下來在找到res文件夾。
3、可以看到res下面有的drawable,右擊res,選擇復制,也就是文字輸入框內加入圖片的執行命令,當然也可以直接快捷鍵Ctrl+V。
4、接下來會出現一個框,Newname實際上就是我們剛剛復制的圖片的名字,下面的路徑我們選擇res下的drawable,點擊OK,圖片就復制過去了。

H. 我剛學Android不久,用系統自帶的Menu,加了圖片後怎麼沒顯示出來

菜單Memu是用戶界面中最常見的元素之一,使用非常頻繁,在Android中,菜單被分為如下三種,選項菜單(OptionsMenu)、上下文菜單(ContextMenu)和子菜單(SubMenu),以下說的是創建OptionsMenu
一、概述
public boolean onCreateOptionsMenu(Menu menu):使用此方法調用OptionsMenu。
public boolean onOptionsItemSelected(MenuItem item):選中菜單項後發生的動作。
public void onOptionsMenuClosed(Menu menu):菜單關閉後發生的動作。
public boolean onPrepareOptionsMenu(Menu menu):選項菜單顯示之前onPrepareOptionsMenu方法會被調用,你可以用此方法來根據打當時的情況調整菜單。
public boolean onMenuOpened(int featureId, Menu menu):單打開後發生的動作。
二、默認樣式
默認樣式是在屏幕底部彈出一個菜單,這個菜單我們就叫他選項菜單OptionsMenu,一般情況下,選項菜單最多顯示2排每排3個菜單項,這些菜單項有文字有圖標,也被稱作Icon Menus,如果多於6項,從第六項開始會被隱藏,在第六項會出現一個More里,點擊More才出現第六項以及以後的菜單項,這些菜單項也被稱作Expanded Menus。下面介紹。
1.main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="請點擊 Menu鍵顯示選項菜單" android:id="@+id/TextView02" />
</LinearLayout>

2.重載onCreateOptionsMenu(Menu menu)方法
重載onCreateOptionsMenu(Menu menu)方法,並在此方法中添加菜單項,最後返回true,如果false,菜單則不會顯示。

3.為菜單項注冊事件
使用onOptionsItemSelected(MenuItem item)方法為菜單項注冊事件
public boolean onOptionsItemSelected(MenuItem item)

I. android RadioButton 怎麼設置只顯示圖片不顯示圖片,因為圖片上已經有文字了

只需要給RadioButton配置一個Selector背景選擇器即顯示圖片。
1.創建mylist_view.xml文件
首先在res目錄下新建drawable文件夾,再在新建的drawable文件夾中新建mylist_view.xml,其目錄結構為:res/drawable/mylist_view.xml。

2.根據具體需求編輯mylist_view.xml文件
新建mylist_view.xml文件後,在沒有添加任何屬性時其內部代碼結構為:
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>

3.下面就可以根據項目需求,在其內部定義為自己想要的樣式了,主要屬性如下:
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 默認時的背景圖片-->
<item android:drawable="@drawable/pic1" />
<!-- 沒有焦點時的背景圖片 -->
<item android:state_window_focused="false" android:drawable="@drawable/pic1" />
<!-- 非觸摸模式下獲得焦點並單擊時的背景圖片 -->
<item android:state_focused="true" android:state_pressed="true" android:drawable= "@drawable/pic2" />
<!-- 觸摸模式下單擊時的背景圖片-->
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pic3" />
<!--選中時的圖片背景-->
<item android:state_selected="true" android:drawable="@drawable/pic4" />
<!--獲得焦點時的圖片背景-->
<item android:state_focused="true" android:drawable="@drawable/pic5" />
</selector>

4.引用mylist_view.xml文件
android:background="@drawable/mylist_view"

熱點內容
安卓加速器怎麼關 發布:2025-05-15 11:38:16 瀏覽:463
密碼鎖壞了如何打開 發布:2025-05-15 11:30:19 瀏覽:837
怎樣增加共享文件夾連接數量 發布:2025-05-15 11:24:50 瀏覽:961
安卓如何關閉單應用音量 發布:2025-05-15 11:22:31 瀏覽:351
抖音電腦後台伺服器中斷 發布:2025-05-15 11:11:59 瀏覽:307
sql2008伺服器 發布:2025-05-15 11:03:27 瀏覽:306
我的世界pe伺服器創造 發布:2025-05-15 10:51:17 瀏覽:608
移動端打吃雞要什麼配置 發布:2025-05-15 10:48:16 瀏覽:756
我的世界哪五個伺服器被炸了 發布:2025-05-15 10:36:16 瀏覽:994
ehcache存儲對象 發布:2025-05-15 10:35:31 瀏覽:528