在XML文件中,我们可以为视图分配ID android:id="@+id/something",然后调用findViewById(),但在以编程方式创建视图时,如何分配ID?
我认为setId()与默认分配不同.setId()是额外的.
任何人都可以纠正我吗?
android android-view findviewbyid android-resources android-identifiers
我很快就是早起的鸟儿.我有一本字典.我想获得我的密钥值.关键方法的对象对我不起作用.任何人都可以帮助我吗?
这是我的字典;
var companies = ["AAPL" : "Apple Inc", "GOOG" : "Google Inc", "AMZN" : "Amazon.com, Inc", "FB" : "Facebook Inc"]
for (name) in companies.key {
println(companies.objectForKey("AAPL"))
}
Run Code Online (Sandbox Code Playgroud) 怎么requestWindowFeature()办?我用它来创建一个自定义标题栏,但我真的不明白它的用途是什么.
该SDK文档中提供的说明这里就没有意义了.
我在消息平台上工作,如whatsup.When发送消息ı必须更新屏幕,因为我正在db中获取数据.当我按下发送按钮ı必须更新视图.我用谷歌搜索,但不能确切的解决方案.任何人都可以帮我吗?
编辑:
我的代码:
RelativeLayout layout=new RelativeLayout(this);
LayoutParams lparams = new LayoutParams(
1200,LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(lparams);
//layout.setBackgroundResource(R.drawable.bubble);
// Creating a new TextView
TextView tv = new TextView(this);
tv.setText(msgdesc[i]);
layout.setGravity(Gravity.RIGHT);
tv.setPadding(30, 10, 0, 0);
layout.addView(tv);
bubbleLayout.addView(layout);
Run Code Online (Sandbox Code Playgroud) 可能重复:
src和ImageView的背景有什么区别
android:background和之间有什么区别android:src?他们的工作是否相同?
我想以编程方式进行相对布局并设置android:layout_widht = 60 android:layout_height = 60.当我以编程方式执行时,它是否填满所有屏幕?我怎样才能做到这一点?
我的代码:`
RelativeLayout relativeLayout=new RelativeLayout(getContext());
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rel_btn.height = 60;
rel_btn.width = 60;
relativeLayout.setLayoutParams(rel_btn);
this.setBackgroundResource(com.example.R.drawable.line);`
Run Code Online (Sandbox Code Playgroud)
屏幕:

有人在Android项目中使用intellj吗?我想在调试模式下获取截图realdevice我的android项目.
我有一个代码,我正在检索纬度和经度信息.我想知道我需要什么工具才能创建谷歌地图网址.
我不想在地图上显示该信息,但我希望能够创建一个链接(谷歌地图URL为纬度和经度信息).那可能吗?如果是的话,我很感激您是否可以指导我使用哪些工具来实现该功能.
提前致谢.
我想创建一个像真正的后退按钮一样工作的按钮.当我按下后退按钮(我的按钮)时,这与真正的按钮相同.我如何以编程方式进行操作?
我总是得到这个错误.我认为查询是好的.什么是问题?
"引起:android.database.sqlite.SQLiteException:near"to":语法错误:,同时编译:创建表消息(_id整数,msgdesc文本,日期时间戳不为空,由整数非空创建,为非整数非空); "
这是我的代码:
public class ContactListDB extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 2;
private static final String DATABASE_NAME = "MobileMerch";
// Database creation SQL statement
private static final String CREATE_MERCH = "create table Merchendiser" +
"(_id integer primary key, name text not null,surname text not null,username text not null);";
// Database creation SQL statement
private static final String CREATE_MESSAGES = "create table Messages" +
"(_id integer , msgdesc text ,date timestamp not null, createdby integer not …Run Code Online (Sandbox Code Playgroud) 我定义了GetURL方法,以便从网络提供商处找到我的位置,您可以发送以下代码.
如果我使用Activity在我的主类中定义该代码段,这很好用但是当我想创建一个单独的类(例如GetLocation类)时,我不能使用getSystemService方法并且我在主题中收到错误(getSystemService未定义类型for GetLocation).关于这个主题有几个条目,但我不完全理解.
这是一个菜鸟问题,所以在回答时考虑到这一点:)谢谢你们.
public String GetURL () {
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String locationProvider = LocationManager.NETWORK_PROVIDER;
mostRecentLocation = locationManager.getLastKnownLocation(locationProvider);
if(mostRecentLocation != null) {
double lat = mostRecentLocation.getLatitude();
double lng = mostRecentLocation.getLongitude();
currentLocation = "Lat: " + lat + " Lng: " + lng;
Log.e("LOCATION -------------", currentLocation + "");
}
return currentLocation;
}
Run Code Online (Sandbox Code Playgroud) 我想像ipad一样拆分屏幕.我不知道确切的名字.任何人都知道我该怎么做或者这个例子?
android ×11
android-ui ×2
android-view ×1
dictionary ×1
findviewbyid ×1
key-value ×1
split ×1
sqlite ×1
swift ×1