我是android领域的新手..
我正在开发一个基于测验的应用程序.当用户打开此应用时,将有1个问题和4个选项(单选按钮)单选按钮将被取消选中但是当用户回答1个任务并且当他去下一个任务单选按钮时问题将被检查.我想取消选中/重置每个问题的单选按钮.我该怎么做?
预先感谢...
answ1=new ArrayList<String>(new ArrayList<String>(answ1));
btn_practice1.setText(answ1.get(0));
btn_practice2.setText(answ1.get(1));
btn_practice3.setText(answ1.get(2));
btn_practice4.setText(answ1.get(3));
btn_practicerg.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton radioButton = (RadioButton)group. findViewById(checkedId); //line 262
String temp = radioButton.getText().toString();
switch(btn_practicerg.getCheckedRadioButtonId()){
case R.id.RB1:
if (btn_practice1.isChecked()){
btn_practice2.setChecked(false);
btn_practice3.setChecked(false);
btn_practice4.setChecked(false);
}
break;
case R.id.RB2:
if (btn_practice2.isChecked()){
btn_practice1.setChecked(false);
btn_practice3.setChecked(false);
btn_practice4.setChecked(false);
}
break;
case R.id.RB3:
if (btn_practice3.isChecked()){
btn_practice1.setChecked(false);
btn_practice2.setChecked(false);
btn_practice4.setChecked(false);
}
break;
case R.id.RB4:
if (btn_practice4.isChecked()){
btn_practice1.setChecked(false);
btn_practice2.setChecked(false);
btn_practice3.setChecked(false);
}
break;
default:
btn_practice1.setChecked(false);
btn_practice2.setChecked(false);
btn_practice3.setChecked(false);
btn_practice4.setChecked(false);
}
ImageView nextBtn = (ImageView) findViewById(R.id.nxt_btn);
nextBtn.setOnClickListener(new …
Run Code Online (Sandbox Code Playgroud) 我发现很多问题要将字体类型设置为webview.我试过我无法修复.
我的assest文件夹中有10个html文件.在webview中一个接一个地显示滑动,直到它的工作正常,现在我需要按钮点击更改字体类型(对于我加载10个文件的所有html页面).如何在webview中更改我的html显示的字体类型.
第一路
mainContent.getSettings().setJavaScriptEnabled(true);
WebSettings webSettings = mainContent.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
mainContent.requestFocusFromTouch();
mainContent.setWebViewClient(new WebViewClient());
mainContent.setWebChromeClient(new WebChromeClient());
mainContent.loadUrl("file:///android_asset/"+filename.get(position));
Typeface font = Typeface.createFromAsset(getAssets(), "myfont.ttf");
webSettings.setFixedFontFamily(font);
webSettings.setDefaultFontSize(20);
Run Code Online (Sandbox Code Playgroud)
第二种方式
我已经获得了html的内容,并且我已经传入一个字符串,我无法传递给它,如果内容正确传递,这将有效.
mainContent.getSettings().setJavaScriptEnabled(true);
WebSettings webSettings = mainContent.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
mainContent.requestFocusFromTouch();
mainContent.setWebChromeClient(new WebChromeClient());
mainContent.loadUrl("file:///android_asset/"+filename.get(position));
mainContent.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mainContent.setWebViewClient(null);
mainContent.loadUrl("javascript:window.HTMLOUT.processHTML('<div>'+document.getElementsByTagName('div')[0].innerHTML+'</div>');");
String pish = "<html><head><style type=\"text/css\">@font-face {font-family: MyFont;src: url(\"file:///android_asset/fonts/Kelvetica.ttf\")}body {font-family: MyFont;font-size: medium;text-align: justify;}</style></head><body>";
String pas = "</body></html>";
String myHtmlString = pish + page + pas; // here i can't able …
Run Code Online (Sandbox Code Playgroud) 加密字符串时,它会'\n'
在字符串末尾生成。
这就是我进行加密的方式
public static String encrypt(String plainText) throws Exception {
byte[] tdesKeyData = Consts.getSecretKey().getBytes();
byte[] myIV = Consts.getInitializationVector().getBytes();
SecretKeySpec myKey = new SecretKeySpec(tdesKeyData, "DES");
IvParameterSpec ivspec = new IvParameterSpec(myIV);
Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS7Padding");
cipher.init(Cipher.ENCRYPT_MODE, myKey, ivspec);
byte[] plainTextBytes = plainText.getBytes("UTF-8");
byte[] buf = cipher.doFinal(plainTextBytes);
byte[] base64Bytes = Base64.encode(buf, Base64.DEFAULT);
String base64EncryptedString = new String(base64Bytes);
return base64EncryptedString;
}
Run Code Online (Sandbox Code Playgroud)
请有人指导我,我在这里做错了什么?提前致谢。
当我在电视上安装应用程序时,我可以运行它并执行所有操作,但我不知道为什么应用程序图标没有显示在电视的主屏幕上。主要是它不显示在 1080p 电视上
这是我的 AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.demo.tv">
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="true" />
<permission
android:name="com.app.demo.tv.ACCESS_VIDEO_DATA"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".Application"
android:allowBackup="true"
android:banner="@drawable/app_icon"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".HomeActivity"
android:label="@string/app_name"
android:theme="@style/HomeTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/LandingAndOtherTheme" />
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud) 我在数组中有一个url字符串.如何在gridview中显示视频的网址,然后单击下一个屏幕中的网格播放.怎么实现这个?任何人指导我..
我尝试了图像它的工作正常..如何实现视频,数组是string..url ..
public class act extends Activity {
/** Called when the activity is first created. */
//Integer[] imageIDs={R.drawable.icon,R.drawable.icon,R.drawable.icon};
String uri1="https://i3.ytimg.com/vi/bQaWsVQSLdY/default.jpg";
String uri2="https://i4.ytimg.com/vi/cJQCniWQdno/mqdefault.jpg";
String uri3="https://i1.ytimg.com/vi/D8dA4pE5hEY/mqdefault.jpg";
String[] urls={uri1,uri2,uri3};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GridView grd=(GridView)findViewById(R.id.gridView1);
grd.setAdapter(new ImageAdapter(this));
grd.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,View v,int pos,long id)
{
Toast.makeText(getBaseContext(),"pic"+(pos+1)+"select ",Toast.LENGTH_SHORT).show();
}
});
}
public class ImageAdapter extends BaseAdapter
{
private Context context;
private int itemBackground;
ImageAdapter(Context c)
{
context=c;
TypedArray a=obtainStyledAttributes(R.styleable.Gallery1);
itemBackground=a.getResourceId(R.styleable.Gallery1_android_galleryItemBackground,0);
a.recycle();
}
public int getCount() …
Run Code Online (Sandbox Code Playgroud) 我在listview上遇到错误,我尝试了很多方法.我没弄明白.什么我失踪了?我应该做些什么改变?如果我尝试使用arrayadapter没有对话成功运行.我是android的新手.我非常感谢...
码-
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
viewList = Topic.this.getLayoutInflater().inflate(R.layout.list_row, null);
dialogMarketList = new Dialog(Topic.this);
dialogMarketList.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialogMarketList.setContentView(viewList);
dialogMarketList.show();
Display newDisplay = getWindowManager().getDefaultDisplay();
int width = newDisplay.getWidth();
lvForDialog = (ListView) viewList.findViewById(R.id.ListView);
ArrayAdapter<String> adapter =(new ArrayAdapter<String>(Topic.this,R.layout.topic_row,R.id.childname, groupnamelist));
lvForDialog.setAdapter(adapter);
// lv = (ListView) findViewById(R.id.ListView);
// ArrayAdapter<String>adapter=new ArrayAdapter<String>(Topic.this,android.R.layout.simple_list_item_1,groupnamelist);
// lv.setAdapter(adapter);
lvForDialog.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,long id)
Run Code Online (Sandbox Code Playgroud)
topic_row的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/childname"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
LogCat-
450: E/AndroidRuntime(1540): FATAL …
Run Code Online (Sandbox Code Playgroud) 我是android新手..
我正在使用sqlite数据库.在我的图像数据库中,我有一行.我正在android中正确获取图像.但是数据库中没有图像,而且在我的drawable中,我在图像视图中得到了空白区域.怎么解决这个?任何人帮助我..我的代码中也没有错误.
提前致谢...
我正在做门户网站应用程序.
通过使用AsyncTask <>我获取json值并显示.
我的应用程序在Android 2.3.3中运行良好,但是当我在Android 4.1.2中运行该应用程序时,它会抛出错误.我已经使用google并根据它进行了更改,但我仍然在4.1.2中收到错误
我在清单中也包括了这行...
<uses-permission android:name="android.permission.INTERNET" />
Run Code Online (Sandbox Code Playgroud)
我也删除了runOnUiThread部分,onPostExecute(String file_url)
之后它也抛出了错误.
任何帮助,将不胜感激.
我的代码
class LoadAllgroups extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(progress_bar_type);
}
protected String doInBackground(String... args) {
// here my codes
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
gnamelist=new ArrayList<String>(new LinkedHashSet<String>(gnamelist));
runOnUiThread(new Runnable() {
public void run() {
createExpandableListViewDialog();
}
});
return;
}
}
Run Code Online (Sandbox Code Playgroud)
logcat的
07-29 00:29:47.860: E/AndroidRuntime(947): FATAL EXCEPTION: main
07-29 00:29:47.860: E/AndroidRuntime(947): android.os.NetworkOnMainThreadException
07-29 00:29:47.860: E/AndroidRuntime(947): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
07-29 …
Run Code Online (Sandbox Code Playgroud) 我的sqlite数据库中有两个表,其中列名称为solution,solutionimage,id表示tableA和tableB.我想,从tableB解决方案,solutionimage复制到tableA分别匹配两个表中的id,怎么做?
我有谷歌它尝试但我没有得到它..任何人帮助我.非常感谢提前.