如何使用TextWriter对象清除文本文件的所有数据?
mt文件名是:user_name.txt
谢谢.
我正在使用jetty服务器(来自org.mortbay.jetty.Server)
Server server = new Server(8080);
Run Code Online (Sandbox Code Playgroud)
我如何获取我的服务器地址,以便我可以发送消息进行测试?谢谢.
有没有办法通过字符串行子串?
有点像:String.substring(line_num);
或者我们通过计算索引来手动完成它?
我实现了自定义微调器:
public class MyAdapter extends ArrayAdapter<String>
{
public MyAdapter(Context context, int textViewResourceId,
String[] objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
}
@Override
public View getDropDownView(int position, View convertView,ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
public View getCustomView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater=getLayoutInflater();
View row= inflater.inflate(R.layout.spinner, parent, false);
TextView label=(TextView)row.findViewById(R.id.textView1);
label.setText(data1[position]);
ImageView icon=(ImageView)row.findViewById(R.id.imageView1);
icon.setImageResource(images[position]);
return row;
}
}
Run Code Online (Sandbox Code Playgroud)
并设置为这样的微调器: …
我有活动A,它有一个带自定义适配器的ListView.
自定义适配器(适用于每个列表视图项)具有一个调用自定义对话框的按钮.
在此对话框中正在执行一个操作,作为响应,我想调用活动A上的UI更新.
这是我对简历代码的活动:
@Override
public void onResume()
{
super.onResume();
setUI();
}
Run Code Online (Sandbox Code Playgroud)
但是当我打电话的时候
dialog.dismiss();
Run Code Online (Sandbox Code Playgroud)
该对话框关闭,而不调用Activity A OnResume方法benig.
我如何捕捉和更新活动ui?
我想在现有布局的底部添加一个视图,而不管 Activity 布局文件中定义的 ViewGroup 的类型(线性、相对等...)
活动布局文件如下所示:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Ad"
android:layout_centerInParent="true"
android:onClick="showAdd"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是放置视图的代码:
ViewGroup rootView = (ViewGroup)((Activity) m_context).findViewById(android.R.id.content);
RelativeLayout.LayoutParams lay = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
lay.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
rootView.addView(adView,lay);
Run Code Online (Sandbox Code Playgroud)
问题是 View 出现在屏幕中间而不是底部,正如预期的那样
构建我的应用程序时出现此重复错误:
addJar(...facebookadapter-4.0.3.jar):条目
重复条目:com/facebook/ads/AbstractAdListener.class
我得到这个的原因是我的应用程序编译 Facebook 模块,一个属于适配器,一个属于其原始 SDK:
编译 ('com.ironsource.adapters:facebookadapter:4.0.3@jar') 编译 'com.facebook.android:audience-network-sdk:4.27.0' 编译 'com.google.ads.mediation:facebook:4.27. 0.0'
因此,作为解决方案,我试图从包含适配器 jar 编译语句的模块中排除该组:
compile ('com.ironsource.adapters:facebookadapter:4.0.3@jar') {
exclude (group: 'com/facebook/ads')
}
Run Code Online (Sandbox Code Playgroud)
但是,当我再次构建我的应用程序时,它无法从同一个适配器中说明相同的原因
知道为什么不排除这些课程吗?
我创建了一个目录:
def createDir(dir_name):
try:
os.mkdir(dir_name)
return True;
except:
return False
createDir(OUTPUT_DIR)
Run Code Online (Sandbox Code Playgroud)
现在我想创建一个用于写入的文件,并将其放在我新创建的目录中,即内部OUTPUT_DIR.我怎样才能做到这一点?
我在AS400表上运行SQL查询.
我事先不知道我在SQL中提取的列名.
在我的ResultSet中,我需要:
获取结果集列(结果记录的MetaData - 一次).
对于集合中的每个记录,获取列的值.
我怎样才能做到这一点?
我正在尝试将代理分配给 admob 插页式广告,以便我可以处理广告事件。
GADInterstitialDelegate 实现类:
class AdDelegate: NSObject, GADInterstitialDelegate
{
//Interstitial delegate
func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
println("interstitialDidFailToReceiveAdWithError:\(error.localizedDescription)")
}
func interstitialDidReceiveAd(ad: GADInterstitial!) {
println("interstitialDidReceiveAd")
}
func interstitialWillDismissScreen(ad: GADInterstitial!) {
println("interstitialWillDismissScreen")
}
func interstitialDidDismissScreen(ad: GADInterstitial!) {
println("interstitialDidDismissScreen")
}
func interstitialWillLeaveApplication(ad: GADInterstitial!) {
println("interstitialWillLeaveApplication")
}
func interstitialWillPresentScreen(ad: GADInterstitial!) {
println("interstitialWillPresentScreen")
}
Run Code Online (Sandbox Code Playgroud)
}
委托给广告的分配:
add.delegate = AdDelegate()
Run Code Online (Sandbox Code Playgroud)
问题是广告事件没有在 AdDelegate 实现类中触发(广告正确显示)知道为什么吗?
我无法在与分配给广告对象的类相同的类中实现 GADInterstitialDelegate,因为广告对象是在类 func 中创建的,这会导致编译器错误
我正在使用:`private void get_stocks_data(){byte [] result; byte [] buffer = new byte [4096];
WebRequest wr = WebRequest.Create("http://www.tase.co.il/TASE/Pages/ExcelExport.aspx?sn=he-IL_ds&enumTblType=AllSecurities&Columns=he-IL_Columns&Titles=he-IL_Titles&TblId=0&ExportType=1");
using (WebResponse response = wr.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (MemoryStream memoryStream = new MemoryStream())
{
int count = 0;
do
{
count = responseStream.Read(buffer, 0, buffer.Length);
memoryStream.Write(buffer, 0, count);
} while (count != 0);
result = memoryStream.ToArray();
write_data_to_excel(result);
}
}
}`
Run Code Online (Sandbox Code Playgroud)
下载excel文件,
并且这种方法可以在我的计算机上填充文件:
private void write_data_to_excel(byte[] input)
{
StreamWriter str = new StreamWriter("stockdata.xls");
for (int i = 0; input.Length > …Run Code Online (Sandbox Code Playgroud) android ×4
java ×3
c# ×2
.net ×1
admob ×1
build.gradle ×1
db2 ×1
gradle ×1
httprequest ×1
ibm-midrange ×1
interstitial ×1
ios ×1
jetty ×1
python ×1
sql ×1
string ×1
swift ×1
web ×1