- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试构建一个通用应用程序,我可以在其中加载所有在线资源,以便根据输入加载某些资源。可能吗?
最佳答案
是的,可以在运行时从在线服务器加载图像和文本等资源。您所要做的就是
调用你的网络服务
从响应中获取资源(我想,文本和图像是您的要求)
膨胀你的布局
设置他们的值(value)观/资源。
编辑:
第三段指出:
For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime; it only works with an XmlPullParser returned from a compiled resource (R.something file.)
我没有提到在运行时创建 yourLayout.xml,否则我就错了。
为了证明我的观点,我举了一个来自那个项目的类(class)的例子:
public class WriteScreen extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.writescreen);
title=(TextView)findViewById(R.id.writescreentitle);
array_listaudiodurationurl=new ArrayList<String>();
array_listcreatorname=new ArrayList<String>();
array_listtype=new ArrayList<String>();
array_listurl=new ArrayList<String>();
array_listcreatorid=new ArrayList<String>();
array_listcreatoravatar=new ArrayList<String>();
array_listid=new ArrayList<String>();
array_listcontent=new ArrayList<String>();
array_listduration=new ArrayList<String>();
array_listtype1=new ArrayList<String>();
array_listimagetype=new ArrayList<String>();
array_listimageurl=new ArrayList<String>();
array_listurl1=new ArrayList<String>();
array_listlastmodified=new ArrayList<String>();
array_listcreated=new ArrayList<String>();
array_listmaintype=new ArrayList<String>();
array_listsource=new ArrayList<String>();
array_listaudiourl=new ArrayList<String>();
Intent in =getIntent();
eId = in.getStringExtra("EventsId");
tit=in.getStringExtra("Title");
title.setText(tit);
mypref = PreferenceManager.getDefaultSharedPreferences(WriteScreen.this);
username = mypref.getString("username", "0");
password = mypref.getString("Password", "0");
write=(Button)findViewById(R.id.writescreenwritebtn);
moderate =(Button)findViewById(R.id.writescreenmoderate);
users=(Button)findViewById(R.id.writescreenusers);
try
{
try
{
writescreen();
}
catch (JSONException e)
{
e.printStackTrace();
}
}
catch (ClientProtocolException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
writelowerparts();
}
public void playAudio()
{
if (WriteScreen.this.audioStreamer.getMediaPlayer().isPlaying())
{
WriteScreen.this.audioStreamer.getMediaPlayer().pause();
}
else
{
WriteScreen.this.audioStreamer.getMediaPlayer().start();
WriteScreen.this.audioStreamer.startPlayProgressUpdater();
}
isPlaying = !isPlaying;
}
public void writelowerparts()
{
boolean isgrey=true;
TableLayout tl = (TableLayout)findViewById(R.id.myTableLayoutwritescreen);
tl.setOrientation(LinearLayout.VERTICAL);
if (tl != null)
{
tl.removeAllViews();
}
if(array_listcreatorid.size() > 0 )
{
LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
LayoutParams lpAddRow = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
LayoutParams lpImageView = new LayoutParams(MyEvents.width - (MyEvents.width/2), LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
for( i = 0; i < array_listcreatorid.size(); i++)
{
Calendar calendar = Calendar.getInstance();
int ro = calendar.getTimeZone().getRawOffset();
int dst = calendar.getTimeZone().getDSTSavings();
int startInd = array_listlastmodified .get(i).indexOf("(");
int EndInd = array_listlastmodified.get(i).indexOf("+") ;
String createdDate = array_listlastmodified.get(i).substring(startInd + 1, EndInd);
long created1 = Long.parseLong(createdDate) + ro + dst;
Date cDate = null;
SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss ");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));//TimeZone.getDefault());
String dateString = formatter.format(new Date(created1));
calendar.setTimeInMillis(created1);
calendar.setTimeZone(TimeZone.getDefault());
TableRow tr = new TableRow(this);
tr.setLayoutParams(lp);
View itemView = new View(this);
Bitmap bm = getBitmapFromUrl(array_listcreatoravatar.get(i));
if(array_listmaintype.get(i).equalsIgnoreCase("text"))
{
itemView = inflater.inflate(R.layout.writescreenlowerparts, null);
ImageView writescreenimageview=new ImageView(this);
TextView writescreenposttext = new TextView(this);
TextView writescreenusernametext = new TextView(this);
TextView writescreendatetext=new TextView(this);
TextView writescreensourcetext=new TextView(this);
writescreensourcetext=(TextView)itemView.findViewById(R.id.writescreensourcetext);
writescreendatetext=(TextView)itemView.findViewById(R.id.writescreendatetext);
writescreenposttext=(TextView)itemView.findViewById(R.id.writescreenposttext);
writescreenusernametext=(TextView)itemView.findViewById(R.id.writescreenusernametext);
LayoutParams param = new LayoutParams(MyEvents.width-90, LayoutParams.WRAP_CONTENT);
writescreenposttext.setLayoutParams(param);
if(array_listsource.get(i).equalsIgnoreCase("mobile"))
{
writescreensourcetext.setText(" via mobile");
}
else
{
writescreensourcetext.setText("");
}
writescreenposttext.setText(""+array_listcontent.get(i));
writescreenusernametext.setText(array_listcreatorname.get(i)+" at ");
int thisHours = calendar.getTime().getHours();
if (thisHours > 12)
{
thisHours = thisHours - 12;
}
String thisH = "" + thisHours;
if (thisHours == 0)
{
thisH = "00";
}
String amPM = calendar.get(Calendar.AM_PM)== 0?"AM":"PM";
if(calendar.getTime().getMinutes() < 10)
{
writescreendatetext.setText(thisH + ":0" + calendar.getTime().getMinutes() + " " + amPM);
}
else
{
writescreendatetext.setText(thisH + ":" + calendar.getTime().getMinutes() + " " + amPM);
}
Log.v("#############################",dateString );
Log.v("----------------------", array_listcreatorname.get(i));
writescreenimageview=(ImageView)itemView.findViewById(R.id.writescreenimageview);
writescreenimageview.setImageBitmap(bm);
if(isgrey==false)
{
TableRow tabttr1=new TableRow(this);
tabttr1.setBackgroundDrawable(getResources().getDrawable(R.drawable.topredline));
tabttr1.setLayoutParams(lp);
tl.addView(tabttr1, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
}
}
else if(array_listmaintype.get(i).equalsIgnoreCase("image"))
{
itemView= inflater.inflate(R.layout.writeimagelayout, null);
TextView writescreencontent =new TextView(this);
TextView writescreenimagedatetext =new TextView(this);
TextView writescreenusernameimagetext =new TextView(this);
ImageView writescreenimagetypeimage=new ImageView(this);
ImageView writescreenbigtypeimage=new ImageView(this);
TextView writescreenimagesourcetext =new TextView(this);
writescreenimagesourcetext=(TextView) itemView.findViewById(R.id.writescreenimagesourcetext);
if(array_listsource.get(i).equalsIgnoreCase("mobile"))
{
writescreenimagesourcetext.setText(" via mobile");
}
else
{
writescreenimagesourcetext.setText("");
}
writescreencontent=(TextView) itemView.findViewById(R.id.writecaption);
writescreenimagetypeimage=(ImageView)itemView.findViewById(R.id.writescreenimagetypeimage);
writescreenbigtypeimage=(ImageView)itemView.findViewById(R.id.writescreenbigtypeimage);
writescreenbigtypeimage.setTag(i);
if(array_listcontent.get(i).length() > 1)
{
writescreencontent.setText(array_listcontent.get(i));
}
writescreenbigtypeimage.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
int j = Integer.valueOf(v.getTag().toString());
Intent in=new Intent(WriteScreen.this,FullImage.class);
fullimage= array_listimageurl.get(j);
Log.v("%%%%%%%%%%%%%%%%%%%%%%%%%%%%",array_listimageurl.get(j));
startActivity(in);
}
});
writescreenusernameimagetext=(TextView)itemView.findViewById(R.id.writescreenusernameimagetext);
writescreenimagedatetext=(TextView)itemView.findViewById(R.id.writescreenimagedatetext);
writescreenusernameimagetext.setText(array_listcreatorname.get(i)+ " at ");
int thisHours = calendar.getTime().getHours();
if (thisHours > 12)
{
thisHours = thisHours - 12;
}
String thisH = "" + thisHours;
if (thisHours == 0)
{
thisH = "00";
}
String amPM = calendar.get(Calendar.AM_PM)== 0?"AM":"PM";
// myeventstime1.setText(cDate.toGMTString().substring(cDate.toGMTString().indexOf(":")-3).trim());
if(calendar.getTime().getMinutes() < 10)
{
writescreenimagedatetext.setText(thisH + ":0" + calendar.getTime().getMinutes() + " " + amPM);
}
else
{
writescreenimagedatetext.setText(thisH + ":" + calendar.getTime().getMinutes() + " " + amPM);
}
String s = array_listimageurl.get(i);
Bitmap bm1 = getBitmapFromUrl(s);
writescreenimagetypeimage.setImageBitmap(bm);
writescreenbigtypeimage.setLayoutParams(lpImageView);
writescreenbigtypeimage.setImageBitmap(bm1);
if(isgrey==false)
{
TableRow tabttr1=new TableRow(this);
tabttr1.setBackgroundDrawable(getResources().getDrawable(R.drawable.topredline));
tabttr1.setLayoutParams(lp);
tl.addView(tabttr1, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
}
}
else if(array_listmaintype.get(i).equalsIgnoreCase("video"))
{
itemView= inflater.inflate(R.layout.writescreenvideo, null);
ImageView writescreenimagesmallvideotype=new ImageView(this);
ImageView writescreenbigvideotype=new ImageView(this);
TextView writescreencontentvideotype =new TextView(this);
TextView writescreenusernamevideotype =new TextView(this);
TextView writescreendateandtimevideotype =new TextView(this);
TextView writescreensourcevideotype =new TextView(this);
writescreensourcevideotype=(TextView)itemView.findViewById(R.id.writescreensourcevideotype);
if(array_listsource.get(i).equalsIgnoreCase("mobile"))
{
writescreensourcevideotype.setText(" via mobile");
}
else
{
writescreensourcevideotype.setText("");
}
writescreenimagesmallvideotype=(ImageView)itemView.findViewById(R.id.writescreenimagesmallvideotype);
writescreenbigvideotype=(ImageView)itemView.findViewById(R.id.writescreenbigvideotype);
writescreencontentvideotype=(TextView)itemView.findViewById(R.id.writescreencontentvideotype);
writescreenusernamevideotype=(TextView)itemView.findViewById(R.id.writescreenusernamevideotype);
writescreendateandtimevideotype =(TextView)itemView.findViewById(R.id.writescreendateandtimevideotype);
writescreencontentvideotype.setText(array_listcontent.get(i));
writescreenusernamevideotype.setText(array_listcreatorname.get(i)+" at ");
int thisHours = calendar.getTime().getHours();
if (thisHours > 12)
{
thisHours = thisHours - 12;
}
String thisH = "" + thisHours;
if (thisHours == 0)
{
thisH = "00";
}
String amPM = calendar.get(Calendar.AM_PM)== 0?"AM":"PM";
if(calendar.getTime().getMinutes() < 10)
{
writescreendateandtimevideotype.setText(thisH + ":0" + calendar.getTime().getMinutes() + " " + amPM);
}
else
{
writescreendateandtimevideotype.setText(thisH + ":" + calendar.getTime().getMinutes() + " " + amPM);
}
writescreenimagesmallvideotype.setImageBitmap(bm);
String s1 = array_listurl1.get(i);
Bitmap bm2 = getBitmapFromUrl(s1);
writescreenbigvideotype.setLayoutParams(lpImageView);
writescreenbigvideotype.setImageBitmap(bm2);
writescreenbigvideotype.setTag(i);
writescreenbigvideotype.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int j = Integer.valueOf(v.getTag().toString());
Intent in=new Intent(WriteScreen.this,WatchVideo.class);
in.putExtra("path", array_listurl.get(j));
startActivity(in);
}
});
if(isgrey==false)
{
TableRow tabttr1=new TableRow(this);
tabttr1.setBackgroundDrawable(getResources().getDrawable(R.drawable.topredline));
tabttr1.setLayoutParams(lp);
tl.addView(tabttr1, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
}
}
else if(array_listmaintype.get(i).equalsIgnoreCase("audio"))
{
itemView= inflater.inflate(R.layout.writescreenaudio, null);
ImageView writescreenimagesmallaudiotype=new ImageView(this);
ImageButton writescreenbuttonaudioplay =new ImageButton(this);
TextView writescreencontentaudiotype =new TextView(this);
TextView writescreenusernameaudiotype =new TextView(this);
//TextView writescreendateandtimeaudiotype =new TextView(this);
ImageButton writescreenbuttonaudiostop =new ImageButton(this);
TextView writescreendurationaudiotype =new TextView(this);
TextView writescreendtimeaudiotype =new TextView(this);
TextView writescreensourceaudiotype =new TextView(this);
writescreenbuttonaudiostop=(ImageButton)itemView.findViewById(R.id.writescreenbuttonaudiostop);
writescreensourceaudiotype=(TextView) itemView.findViewById(R.id.writescreensourceaudiotype);
if(array_listsource.get(i).equalsIgnoreCase("mobile"))
{
writescreensourceaudiotype.setText(" via mobile");
}
else
{
writescreensourceaudiotype.setText("");
}
writescreendurationaudiotype=(TextView)itemView.findViewById(R.id.writescreendurationaudiotype);
writescreendurationaudiotype.setText(array_listaudiodurationurl.get(i));
writescreenbuttonaudioplay=(ImageButton)itemView.findViewById(R.id.writescreenbuttonaudioplay);
writescreenbuttonaudioplay.setTag(i);
writescreenbuttonaudioplay.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
int j = Integer.valueOf(v.getTag().toString());
String path=array_listaudiourl.get(j);
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try
{
mediaPlayer.setDataSource(path);
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalStateException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
try
{
mediaPlayer.prepare();
}
catch (IllegalStateException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(new OnCompletionListener()
{
@Override
public void onCompletion(MediaPlayer paramMediaPlayer)
{
mediaPlayer.stop();
}
});
}
});
writescreenbuttonaudiostop.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View paramView)
{
if(mediaPlayer!=null&& mediaPlayer.isPlaying())
{
mediaPlayer.stop();
}
}
});
writescreenimagesmallaudiotype=(ImageView)itemView.findViewById(R.id.writescreenimagesmallaudiotype);
writescreenimagesmallaudiotype.setImageBitmap(bm);
writescreencontentaudiotype=(TextView) itemView.findViewById(R.id.writescreencontentaudiotype);
writescreencontentaudiotype.setText(array_listcontent.get(i));
writescreenusernameaudiotype=(TextView) itemView.findViewById(R.id.writescreenusernameaudiotype);
writescreenusernameaudiotype.setText(array_listcreatorname.get(i)+" at ");
writescreenbuttonaudiostop=(ImageButton)itemView.findViewById(R.id.writescreenbuttonaudiostop);
writescreendtimeaudiotype=(TextView)itemView.findViewById(R.id.writescreendtimeaudiotype);
int thisHours = calendar.getTime().getHours();
if (thisHours > 12)
{
thisHours = thisHours - 12;
}
String thisH = "" + thisHours;
if (thisHours == 0)
{
thisH = "00";
}
String amPM = calendar.get(Calendar.AM_PM)== 0?"AM":"PM";
// myeventstime1.setText(cDate.toGMTString().substring(cDate.toGMTString().indexOf(":")-3).trim());
if(calendar.getTime().getMinutes() < 10)
{
writescreendtimeaudiotype.setText(thisH + ":0" + calendar.getTime().getMinutes() + " " + amPM);
}
else
{
writescreendtimeaudiotype.setText(thisH + ":" + calendar.getTime().getMinutes() + " " + amPM);
}
if(isgrey==false)
{
TableRow tabttr1=new TableRow(this);
tabttr1.setBackgroundDrawable(getResources().getDrawable(R.drawable.topredline));
tabttr1.setLayoutParams(lp);
tl.addView(tabttr1, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
}
}
tr.addView(itemView);
tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
isgrey=false;
}
}
}
public Drawable getDrawableFromUrl(String url)
{
try{
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is,"img");
return d;
}
catch (Exception e) {
// TODO: handle exception
return null;
}
}
public Bitmap getBitmapFromUrl(String url)
{
HttpGet httpRequest = null;
httpRequest = new HttpGet(url);
Log.v("----------------------", url);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = null;
try
{
response = (HttpResponse) httpclient.execute(httpRequest);
}
catch (ClientProtocolException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = null;
try
{
bufHttpEntity = new BufferedHttpEntity (entity);
}
catch (IOException e)
{
e.printStackTrace();
}
InputStream instream = null;
try
{
instream = bufHttpEntity.getContent();
}
catch (IOException e)
{
e.printStackTrace();
}
Bitmap bm = BitmapFactory.decodeStream(instream);
return bm;
}
public void writescreen() throws ClientProtocolException, IOException, JSONException
{
HttpClient client = new DefaultHttpClient();
String un = android.util.Base64.encodeToString(username.getBytes("UTF-8"),android.util.Base64.NO_WRAP);
String ps = android.util.Base64.encodeToString(password.getBytes("UTF-8"),android.util.Base64.NO_WRAP);
AuthScope as = new AuthScope(hostSecure,443);
UsernamePasswordCredentials upc = new UsernamePasswordCredentials(un,ps);
String auth = android.util.Base64.encodeToString((username + ":" + password).getBytes("UTF-8"),android.util.Base64.NO_WRAP);
((AbstractHttpClient) client).getCredentialsProvider() .setCredentials(as, upc);
BasicHttpContext localContext = new BasicHttpContext();
BasicScheme basicAuth = new BasicScheme();
localContext.setAttribute("preemptive-auth", basicAuth);
HttpHost targetHost = new HttpHost(hostSecure, 443, "https");
HttpGet httpget = new HttpGet("https://apiv1secure.somedomain.com/event/"+eId+"/page?Token=RCFB3m4W"+ "&format=json");
httpget.addHeader("Authorization", "Basic "+ auth);
HttpResponse response = client.execute(targetHost, httpget, localContext);
HttpEntity entity = response.getEntity();
Object content = EntityUtils.toString(entity);
Log.e("", "----------------------------------------"+content);
json = new JSONObject(content.toString());
JSONArray s = null;
s = json.getJSONArray("Posts");
for(int i = 0; i< s.length();i++)
{
String a = s.getString(i);
JSONObject jt = new JSONObject(a);
String postid=jt.getString("Id");
if(jt.has("Content"))
{
String postcontent=jt.getString("Content");
array_listcontent.add(postcontent);
}
else
{
array_listcontent.add("");
}
String creator = jt.getString("Creator");
array_listid.add(postid);
JSONObject jt1 = new JSONObject(creator);
String creatorid = jt1.getString("Id");
String creatoravatar=jt1.getString("Avatar");
String creatorname=jt1.getString("Name");
array_listcreatorname.add(creatorname);
array_listcreatorid.add(creatorid);
array_listcreatoravatar.add(creatoravatar);
mainType=jt.getString("Type");
array_listmaintype.add(mainType);
lastmodified=jt.getString("LastModified");
array_listlastmodified.add(lastmodified);
String createddate=jt.getString("Created");
array_listcreated .add(createddate);
source=jt.getString("Source");
array_listsource.add(source);
if(mainType.equalsIgnoreCase("image"))
{
String Media = "";
if(jt.has("Media"))
{
JSONArray mediatype = jt.getJSONArray("Media");
String d = mediatype.getString(0);
JSONObject jmediatype = new JSONObject(d);
d = mediatype.getString(0);
jmediatype = new JSONObject(d);
imagetype = jmediatype.getString("Type");
String imageurl=jmediatype.getString("Url");
array_listimagetype.add(imagetype);
array_listimageurl.add(imageurl);
array_listtype1.add("0");
array_listurl1.add("0");
array_listduration.add("0");
array_listurl.add("0");
array_listtype.add("0");
array_listaudiourl.add("0");
array_listaudiodurationurl.add("0");
}
}
else if (mainType.equalsIgnoreCase("video"))
{
String Media = "";
if(jt.has("Media"))
{
JSONArray mediatype= jt.getJSONArray("Media");
String d = mediatype.getString(0);
JSONObject jmediatype = new JSONObject(d);
String type=jmediatype.getString("Type");
String url=jmediatype.getString("Url");
String durationtype=jmediatype.getString("Duration");
array_listduration.add(durationtype);
array_listurl.add(url);
array_listtype.add(type);
d = mediatype.getString(1);
jmediatype = new JSONObject(d);
String type1 = jmediatype.getString("Type");
String url1=jmediatype.getString("Url");
array_listtype1.add(type1);
array_listurl1.add(url1);
array_listimagetype.add("0");
array_listimageurl.add("0");
array_listaudiourl.add("0");
array_listaudiodurationurl.add("0");
}
}
else if (mainType.equalsIgnoreCase("text"))
{
array_listimagetype.add("0");
array_listimageurl.add("0");
array_listtype1.add("0");
array_listurl1.add("0");
array_listduration.add("0");
array_listurl.add("0");
array_listtype.add("0");
array_listaudiourl.add("0");
array_listaudiodurationurl.add("0");
}
else if(mainType.equalsIgnoreCase("audio"))
{
JSONArray mediatype= jt.getJSONArray("Media");
String d = mediatype.getString(0);
JSONObject jmediatype = new JSONObject(d);
String audiourl=jmediatype.getString("Url");
String audioduration=jmediatype.getString("Duration");
array_listaudiourl.add(audiourl);
array_listaudiodurationurl.add(audioduration);
array_listimagetype.add("0");
array_listimageurl.add("0");
array_listtype1.add("0");
array_listurl1.add("0");
array_listduration.add("0");
array_listurl.add("0");
array_listtype.add("0");
}
}
}
关于android - 在线获取android资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8831099/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!