我的应用程序中有一些类需要调用需要Context作为参数的Android函数.我没有它,因为类不是Activity类的子类.
解决这个问题的正确方法是什么?
我想知道如何在Android中的SQLite表中插入一个空值.
这是表:
"create table my table (_id integer primary key autoincrement, " +
"deviceAddress text not null unique, " +
"lookUpKey text , " +
"deviceName text , " +
"contactName text , " +
"playerName text , " +
"playerPhoto blob " +
");";
Run Code Online (Sandbox Code Playgroud)
我想使用一个简单的插入命令,execSQL但因为其中一个值是blob我不能这样做(我认为).
所以,我正在使用标准db.Insert命令.如何使其中一个值为null?
如果我只是在ContentValues对象中跳过它会自动在列中放置一个空值吗?
这是我第一次使用RecyclerView进行数据绑定,但不是我第一次使用RecyclerView本身.
由于某些原因,没有调用任何适配器方法 - 甚至不是getItemCount().我的RecyclerView可能是一个愚蠢的问题,与数据绑定无关,但我看不出有什么不妥.
View rootview = inflater.inflate(R.layout.fragment_profile_first, container, false);
// Initialize recycler view
RecyclerView badgesRV = (RecyclerView) rootview.findViewById(R.id.badgesRV);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
llm.setOrientation(LinearLayoutManager.HORIZONTAL);
badgesRV.setLayoutManager(llm);
BadgeAdapter badgeAdapter = new BadgeAdapter(profileObject.badgesEntity.badges);
badgesRV.setAdapter(badgeAdapter);
Run Code Online (Sandbox Code Playgroud)
适配器:
public class BadgeAdapter extends RecyclerView.Adapter<BadgeAdapter.BadgeBindingHolder>{
private static final int MAX_BADGES_TO_DISPLAY = 5;
private BadgeObject[] badges;
public BadgeAdapter(BadgeObject[] badges){
this.badges = badges;
}
@Override
public BadgeBindingHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.profile_badge_row, parent, false);
BadgeBindingHolder holder = new BadgeBindingHolder(v);
return holder;
}
@Override
public …Run Code Online (Sandbox Code Playgroud) android android-custom-view android-recyclerview android-databinding
我正在尝试使用此处描述的过程访问我的设备上的sqlite数据库:如何查看SQLite数据库(无模拟器)?
但是,我继续找不到sqlite3.我假设我打算在行的开头输入带有#(#)符号的命令.我尝试了它并没有得到任何东西.没有它,我收到错误消息.
sqlite3.exe文件肯定存在于路径中.
我必须安装一些东西吗?
有什么办法可以改变RadioButton的布局,还有RadioGroup能识别它吗?
我需要的是布局将包含几个EditText字段,以便当用户选择该按钮时,这些字段变为活动状态.我知道我可以构建一个基于LinearLayout的自定义零件并使用以下方法设置我自己的布局:(LinearLayout)LayoutInflater.from(context).inflate(R.layout.my_layout,this,true)但是无法弄清楚如何做用单选按钮也一样.
我已经尝试过选择在RadioGroup外面添加额外的字段并用按钮排列它们但它根本不起作用.它似乎太依赖于设备.
这就是原始布局的样子:
<RadioGroup
android:id="@+id/time_selector_radio_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/time_selector_hours_prompt"
android:layout_below="@id/time_selector_hours_prompt"
android:layout_alignParentRight="true"
android:gravity="right"
android:orientation="vertical"
android:checkedButton="@+id/time_selector_first_radio"
>
<RadioButton
android:id="@+id/time_selector_first_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
android:button="@drawable/radio_button_selector"
/>
<RadioButton
android:id="@+id/time_selector_second_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
android:button="@drawable/radio_button_selector"
/>
<RadioButton
android:id="@+id/time_selector_third_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
android:button="@drawable/radio_button_selector"
/>
<RadioButton
android:id="@+id/time_selector_hours_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
android:button="@drawable/radio_button_selector"
/>
</RadioGroup>
<TextView
android:id="@+id/time_selector_all_day_prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/time_selector_radio_group"
android:layout_below="@id/time_selector_hours_prompt"
android:layout_marginTop="11dip"
android:text="@string/time_all_day"
/>
<TextView
android:id="@+id/time_selector_before_noon_prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/time_selector_radio_group"
android:layout_below="@id/time_selector_all_day_prompt"
android:layout_marginTop="19dip"
android:text="@string/time_before_noon"
/>
<TextView
android:id="@+id/time_selector_after_noon_prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/time_selector_radio_group"
android:layout_below="@id/time_selector_before_noon_prompt"
android:layout_marginTop="19dip"
android:text="@string/time_after_noon"
/>
<TextView
android:id="@+id/time_selector_starting_time_prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/time_selector_starting_date_prompt"
android:layout_below="@id/time_selector_after_noon_prompt"
android:layout_marginTop="20dip"
android:layout_marginLeft="2dip"
android:text="@string/advanced_time_selector_dialog_starting_time_prompt" …Run Code Online (Sandbox Code Playgroud) 我有PNG图像代表扑克牌.它们是标准颜色,俱乐部和黑桃是空白的,而钻石和红心是红色的.
我希望通过将俱乐部转换为绿色并将钻石转换为蓝色来创建一个4色套牌.
我不想重新绘制它们,但只是手工更换它们似乎很多工作,因为颜色不是全部"纯粹",而是在边缘附近分级.
我该怎么做?
是否可以在AlertDialog的标题和消息中对文本进行右对齐?
我正在展示希伯来语的消息,但它们显示左对齐.
我想知道如果我定义一个基本Activity对象,并将我的所有活动作为其子类,会发生什么.然后我在基类中声明一个静态变量,所有子类都使用SAME静态,还是每个子类都有一个.
例如.我的基类:
public class MyBaseActivity extends Activity{
static int myStatic;
...
....
}
Run Code Online (Sandbox Code Playgroud)
然后:
public class MyActivity1 extends MyBaseActivity {
private void someMethod1(){
myStatic = 1;
}
...
....
}
Run Code Online (Sandbox Code Playgroud)
和
public class MyActivity1 extends MyBaseActivity {
private void someMethod2(){
if (myStatic == 1)
doSomething();
}
...
....
}
Run Code Online (Sandbox Code Playgroud)
如果我现在启动MyActivity1并在"myStatic"中设置一个值.它然后退出然后我启动MyActivity2 - 我是否仍然有第一个活动设置的值?在上面的例子中,"if"语句是真还是假?
我知道,如果我实例化活性1不止一次那么显然我会得到相同的静态变量.但是,这里我每次都要实例化一个不同的子类.
我的印象是,这就是我发生的事情,但我想确定.
我们有一个Android应用程序,要求用户输入Captcha的答案.Captcha是在我们的服务器上生成的.回复时,会将其发送到服务器进行验证.
问题是,因为我必须在请求Captcha之后关闭HttpURLConnection,然后发现回复正在服务器上的另一个会话上运行.因此,Captcha检查失败,因为它取决于会话.
有没有办法保持连接活着或者我应该遵循不同的路径?我知道在相应的iPhone应用程序中,它们保持"连接",因此具有相同的sessionid.
编辑:
CookieManager cookieManager = new CookieManager();
CookieHandler.setDefault(cookieManager);
URL urlObj = new URL(urlPath);
conn = (HttpURLConnection) urlObj.openConnection();
if (urlPath.toLowerCase().startsWith("https:")) {
initializeHttpsConnection((HttpsURLConnection) conn);
}
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Language", "en-US");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", Integer.toString(bodyData.length));
if (_sessionIdCookie != null) {
conn.setRequestProperty("Cookie", _sessionIdCookie);
}
// Connect
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
Run Code Online (Sandbox Code Playgroud) 我更改了我的一个项目的依赖项目,并将我的一个文件作为实验移动到那里.我现在把它移回去,但项目不会运行.它告诉我,我有一个错误,即使我看不到一个,"清洁项目"没有帮助.但是,该项目旁边有一个感叹号.那是什么意思?