我有一个ImageView,我想得到图像的路径,并添加一个String.我想这样做是因为我需要将它发送到我的webservice,就像默认图像一样
我该怎么做 ?
ImageView的
<ImageView
android:id="@+id/ivPerfil"
android:padding="5dp"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/icon_usuario"
android:scaleType="fitXY"
/>
Run Code Online (Sandbox Code Playgroud)
走这条路
ivPerfil = (ImageView)findViewById(R.id.ivPerfil);
Drawable img = getResources().getDrawable(R.drawable.icon_usuario);
String pathImage = img.toString();
Run Code Online (Sandbox Code Playgroud) 我是Android新手(第1天),我被教导如今ImageView使用显示图像()viewFlipper.ViewFlipper适用于少量图像(5左右).但我无法使用它来显示22个图像,因为我得到一个内存不足错误,并且app力关闭.所以我读到这里的StackExchange更换ViewFlipper用ViewPager,我也得到了以下错误.
任何帮助将不胜感激.谢谢.
logcat的: 引擎收录.抱歉,对于patebin,我无法在这里很好地格式化logcat.
第二个ActivityJava类:
package com.droidrish.www.rishabhtatiraju;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.Button;
public class photoActivity extends Activity{
ViewPager vf;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.photography);
vf = (ViewPager)findViewById(R.id.viewpager);
}
Run Code Online (Sandbox Code Playgroud)
第二个Activity布局:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true">
<ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewpager">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/p1"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/p2"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/p3"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/p4"/> …Run Code Online (Sandbox Code Playgroud) 我想将TextView组件的文本更改为我已经创建的另一个文本strings.xml.当应用程序启动时,显示的文本存储在strings.xml名称"help0"下.我想以编程方式将此名称设置为名称为"help00"的字符串,方法是在名称处放置另一个"0".到目前为止,我已经写了这段代码:
String help = "0";
help = help + "0";
final TextView help = (TextView) findViewById(R.id.help);
help.setText("@string/help" + help);
Run Code Online (Sandbox Code Playgroud)
但是,当我运行应用程序时,文本将更改为"@ string/help00",而不是我在help00下存储的文本strings.xml.
我怎么能解决这个问题?
我试图将这个插件加载到我的一个片段中.我喜欢gradle文件中的dependencie:
compile "com.splitwise:tokenautocomplete:1.3.1@aar"
Run Code Online (Sandbox Code Playgroud)
我的碎片onCreateView看起来像:
View view = inflater.inflate(R.layout.fragment_tutor_setup, container, false);
String[] strings = new String[]{"photoshop",""};
adapter = new ArrayAdapter<String>(getActivity(), R.layout.fragment_tutor_setup, strings);
completionView = (ContactsCompletionView)view.findViewById(R.id.searchView);
completionView.setAdapter(adapter);
if (savedInstanceState == null) {
completionView.setPrefix("Skills: ");
}
return view;
Run Code Online (Sandbox Code Playgroud)
然后我像这样扩展一个ContactsCompletionView:
public class ContactsCompletionView extends TokenCompleteTextView {
public ContactsCompletionView(Context context) {
super(context);
}
public ContactsCompletionView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ContactsCompletionView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected View getViewForObject(Object object) {
String s = …Run Code Online (Sandbox Code Playgroud) 我有一个关联数组,$teams_name_points.阵列的长度未知.
如何以最简单的方式在不知道此数组的键的情况下访问第一个和第四个值?
数组填充如下:
$name1 = "some_name1";
$name2 = "some_name2";
$teams_name_points[$name1] = 1;
$teams_name_points[$name2] = 2;
Run Code Online (Sandbox Code Playgroud)
等等
我想做一些像索引数组一样的事情:
for($x=0; $x<count($teams_name_points); $x++){
echo $teams_name_points[$x];
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?