我正在写一个简单的Android应用程序,它有一个edittext和一个按钮.单击按钮应显示一个警告对话框,其中包含在edittext中输入的文本.为此,我有以下代码:
String txt;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b=(Button)findViewById(R.id.ok);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Text in edit box: " + txt)
.setCancelable(false)
.setTitle("Info")
.setPositiveButton("Done", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {}
});
final AlertDialog alert = builder.create();
// set click listener on the flag to show the dialog box
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText et=(EditText)findViewById(R.id.entry);
txt=et.getText().toString();
alert.show();
}
});
}
Run Code Online (Sandbox Code Playgroud)
上面的代码运行正常,但警告对话框显示 …
我试图将xml布局扩展为自定义ViewGroup.在给布局膨胀之后,ViewGroup只显示布局的根视图,实际上它应该将完整的布局文件显示到ViewGroup.
我在stackoverflow和其他网站上经历了与此相关的其他类似问题,但没有帮助.
这是我的自定义代码ViewGroup:
public class ViewEvent extends ViewGroup {
private final String LOG_TAG="Month View Event";
public ViewEvent(Context context) {
super(context);
}
public ViewEvent(Context context,AttributeSet attrs) {
super(context,attrs);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int childCount= getChildCount();
for(int i=0;i<childCount;i++)
{
Log.i(LOG_TAG, "Child: " + i + ", Layout [l,r,t,b]: " + l + "," + r + "," + t + "," + b); …Run Code Online (Sandbox Code Playgroud) 我必须创建一个能够在Android设备上阅读PDF文档的应用程序.实际上我不希望我的应用程序依赖其他应用程序来阅读PDF文件.
我已经完成了在这里和其他地方提出的问题.他们都直接或间接使用第三方应用程序.
是否有任何API或类似的东西可供我通过它直接在我的应用程序中实现PDF文件的阅读?如何将PDF文档转换为PNG图像?但PDF-PNG方法不允许用户选择文本.
有什么建议?
谢谢
我有以下布局
<merge>
<LinearLayout
android:id="@+id/ll_main"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
/>
<LinearLayout
android:id="@+id/ll_sub"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
/>
</merge>
Run Code Online (Sandbox Code Playgroud)
我想要做的是在运行时显示/隐藏ll_sub布局,setVisibility()但它不起作用.
当我从xml中设置android:visibility="gone"(也是我已经检查过invisible)ll_sub然后它没有显示在屏幕上,这次当我用来setVisibility()在运行时显示这个布局时,它显示但是当我试图隐藏这个布局一旦它是显示然后它没有隐藏.
编辑
我试图通过单击按钮显示/隐藏此线性布局.
LinearLayout ll;
Button minimize;
int visibility=0;
@Override
public void onCreate(Bundle savedInstanceState)
{
ll=(LinearLayout)findViewById(R.id.ll_sub);
minimize=(Button)findViewById(R.id.minimize);
minimize.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
if(visibility==0)
{
visibility=2;
}
else
{
visibility=0;
}
ll.setVisibility(visibility);
}
});
}
Run Code Online (Sandbox Code Playgroud) 我是GWT的新手.我正在尝试连接其中的mysql服务器.
以下是我的项目层次结构:
项目名称hello和包名称是com.hello.默认情况下,GWT会创建3个文件夹
包含GWT入口点的主java文件位于com.hello.client文件夹中,名称为hello.java
我创建了一个类db_conn(文件名是db_conn.java),其中包含与mysql数据库连接所需的所有代码.此文件放在com.hello.server文件夹中.以下是代码
package com.hello.server;
import java.sql.Connection;
import java.sql.DriverManager;
public class db_conn
{
public Connection con;
public db_conn()
{
}
public String ConnectToDB()
{
try
{
String host = "localhost";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "pwd";
Class.forName(driver).newInstance();
con = DriverManager.getConnection(host+db, user, pass);
return "Connected to Database";
}
catch(Exception ex)
{
return ex.toString();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在hello.java文件中(位于com.hello.client文件夹中并包含GWT的主要入口点)我已经导入了上面的类 import com.hello.server.*;
当我试图使用 …
我正在为Android编写一个使用InputStreamfrom 的应用程序Socket.我试图通过这种方式从pc发送文件到android.文件的大小几乎是40kb,在android上我发现它一次只能读取2kb的数据,所以我正在以块的形式阅读它.
我有两种读取字节的方法
1)
while((d=inputStream.read())>=0)
{
imgData[i]=(byte)d;
i++;
if(i>=40054)
{
// do the further processing here like saving it on disk.
i=0;
}
}
Run Code Online (Sandbox Code Playgroud)
2)
while(inputStream.read(byte,0,2048)>=0)
{
//merge this byte to buffer here...
i=i+2048;
if(i>=40054)
{
// do the further processing here like saving it on disk.
i=0;
}
}
Run Code Online (Sandbox Code Playgroud)
形成这两种方法,在性能方面会更快?
我有一个域名和网络空间(网络正在运行,其ASP.net 3.5).我正在开展一个项目,我需要通过互联网连接2台计算机.
是否可以通过简单的ASP.Net网站实现这一目标?我还需要做些什么呢?
谢谢
编辑
实际上我想实时将数据从一台计算机发送到另一台计算机,我的意思是当我们聊天时,我们互相交换文本.我想要实现同样的目标.
我正在尝试从WinFroms迁移到WPF.我有一个使用GDI +在C#中开发的应用程序(类似于MS绘图).我想在WPF中编写相同的应用程序,但我不知道如何执行像GDI +这样的图形操作?
我有一个图像,我想将该特定图像的色调修改为特定值.我知道rgb到hsl和hsl到rgb的转换数学公式但是我无法将这个东西实现到c#中.
以下是伪:
for(x=0;x<image_width;x++)
{
for(y=0;y<image_height;y++)
{
Color oldColor=GetColorFromPixel(x,y);
Color newColor=ModifyHue(oldColor);
SetColorPixel(x,y,newColor);
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个复杂的情况,我需要解析一个很长的字符串.我必须在字符串中查找模式并将该模式替换为另一模式.我知道我可以简单地使用find/replace方法,但我的情况有点不同.
我有一个包含以下模式的字符串
#EPB_IMG#index-1_1.jpg#EPB_IMG
#EPB_IMG#index-1_2.jpg#EPB_IMG
#EPB_IMG#index-1_3.jpg#EPB_IMG
#EPB_IMG#index-1_4.jpg#EPB_IMG
Run Code Online (Sandbox Code Playgroud)
我希望它格式化为
#EPB_IMG#index-1_1.jpg|index-1_2.jpg|index-1_3.jpg|index-1_4.jpg#EPB_IMG
Run Code Online (Sandbox Code Playgroud)
我不太了解Regex并寻求帮助.