小编Jav*_*a D的帖子

如何在单个TextView中显示数组列表中的多行?

我正在开发Android应用程序,因此我希望在单个文本视图中显示四行文本.我的数组列表包含如下数据

客户名称:Nilesh
客户联系方式:23230200
客户城市:浦那

但是当我写代码之后,只有最后一行显示在数组列表中

XML

  <TextView android:id="@+id/kbpViewTvCustNm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="4dp"
            android:layout_marginLeft="8dp"
            android:lines="4"
            android:textIsSelectable="false" />
Run Code Online (Sandbox Code Playgroud)

for (String details : list2)
  {
     custName.setText(details);
  }
Run Code Online (Sandbox Code Playgroud)

android textview

7
推荐指数
1
解决办法
2万
查看次数

如何通过nfc将简单的字符串从android发送到android?

我想通过NFC将一个简单的字符串(text/plain)从一个Android设备发送到另一个.我能够以简单的字符串格式发送消息,并在恩智浦和其他提供商的一些已经制作的应用程序中读取.我在NDEFMessage中发送字符串.

public class MainActivity extends Activity 
{
    private NfcAdapter mAdapter;
    private PendingIntent mPendingIntent;
    private IntentFilter[] mFilters;
    private String[][] mTechLists;
    private TextView mText,txtRead;
    private int mCount = 0;
    Tag detectedTag;
    ReadWrite rd;

    @Override
    public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setContentView(R.layout.activity_main);
    mText = (TextView) findViewById(R.id.text);
    txtRead = (TextView) findViewById(R.id.txtRead);
    mText.setText("Scan a tag");

    rd=new ReadWrite();
    mAdapter = NfcAdapter.getDefaultAdapter(this);
    detectedTag =getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);

    // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
    // will fill in the intent with the …
Run Code Online (Sandbox Code Playgroud)

android nfc

6
推荐指数
0
解决办法
4442
查看次数

每次运行应用程序时,如何生成唯一的随机数?

在我的应用程序中,我想生成9位数的随机数,这样它们就是唯一的.每次运行应用程序时,只应生成一个9位随机数,它应该是唯一的.后来我想将这个号码及其相关数据保存在.txt文件中,这样我就可以在需要时检索与这个唯一号码相关的数据.我该怎么做到这一点?

java random unique

5
推荐指数
3
解决办法
4万
查看次数

单个控制器实例不能用于处理多个请求 - Autofac

Autofac.ContainerBuilder在我的ASP.Net MVC 4应用程序中使用,这使得默认控制器出现问题以生成多个实例.

我试着这样处理它

 builder.RegisterType<AccountController>().As<IController>().PreserveExistingDefaults();
Run Code Online (Sandbox Code Playgroud)

但没用

protected void Application_Start()
    {

      var dataPath = "~/App_Data/" + ConfigurationManager.AppSettings["Blog_Site"];

        var builder = new ContainerBuilder();

        builder.RegisterType<ExtensibleActionInvoker>().As<IActionInvoker>().InstancePerHttpRequest();
        builder.RegisterControllers(Assembly.GetExecutingAssembly()).InjectActionInvoker().InstancePerHttpRequest();

        builder.RegisterModelBinders(Assembly.GetExecutingAssembly());
        builder.RegisterType<JsonRepository>().As<IRepository>().InstancePerLifetimeScope().WithParameter("dataPath", HttpContext.Current.Server.MapPath(dataPath));
        builder.RegisterType<ConfigService>().As<IConfigService>().InstancePerLifetimeScope();
        builder.RegisterType<EntryService>().As<IEntryService>().InstancePerLifetimeScope();
        builder.RegisterType<UserService>().As<IUserService>().InstancePerLifetimeScope();
        builder.RegisterType<MessageService>().As<IMessageService>().InstancePerLifetimeScope();
        builder.RegisterType<CloudService>().As<ICloudService>().InstancePerLifetimeScope();
        builder.RegisterType<Services>().As<IServices>().InstancePerLifetimeScope();

        _containerProvider = new ContainerProvider(builder.Build());

        ControllerBuilder.Current.SetControllerFactory(new AutofacControllerFactory(ContainerProvider));

        AreaRegistration.RegisterAllAreas();
        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(System.Web.Optimization.BundleTable.Bundles);
        AuthConfig.RegisterAuth();

        HtmlHelper.ClientValidationEnabled = true;
        HtmlHelper.UnobtrusiveJavaScriptEnabled = true;

        // Quartz.NET scheduler
        ISchedulerFactory factory = new StdSchedulerFactory();
        var scheduler = factory.GetScheduler();
        scheduler.JobFactory = new AutofacJobFactory(ContainerProvider);
        scheduler.Start();
    }
Run Code Online (Sandbox Code Playgroud)

当我尝试访问默认控制器帐户/管理我得到以下错误.

这我是如何看待的

  @Html.Action("RemoveExternalLogins")

    <h3>Add an external login</h3> …
Run Code Online (Sandbox Code Playgroud)

controller autofac requestfactory asp.net-mvc-4

1
推荐指数
1
解决办法
7425
查看次数

如何使用liferay portlet在db中插入数据

如何使用Liferay在MySql中插入数据?

我已经从edit.jsp 创建了Edit.jsp、view.jsp 我想输入数据并且在view.jsp 中我想显示我的数据。在edit.jsp 中输入的这些数据应该存储在我的mysql 表中。我已经创建了 service.xml、portal-ext.properties。

我也有java文件。请告诉我应该在哪里编写插入逻辑以将数据存储到数据库中。

这是我的 Java 代码。我有edit.jsp 文件和view.jsp 文件,我使用service.xml 文件创建了表,并将我的portal-ext.properties 放在classes 文件夹中。有什么东西不见了吗?我是liferay的新手

package com.portlet;

import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletURL;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portlet.model.testimonial;
import com.liferay.portlet.service.testimonialLocalServiceUtil;

public class Testimonial extends GenericPortlet {

    protected String editJSP;
    protected String viewJSP;
    private static Log _log = LogFactory.getLog(Testimonial.class);

    public void init() throws PortletException 
    {
        editJSP = getInitParameter("edit-jsp"); …
Run Code Online (Sandbox Code Playgroud)

java mysql liferay

1
推荐指数
1
解决办法
1万
查看次数

如果计算机名称包含

我需要创建一个批处理文件,只有在计算机名称包含某些字符串时才会在Active Directory中移动计算机名称对象,例如:

If %computername% contains "LAP" 
( dsmove "CN=%computername%,CN=Computers,DC=domain,DC=local" -newparent"OU=**Laptops**,OU=Computers,OU=Company,DC=domain,DC=local" )

    If %computername% contains "DESK" 
        (dsmove "CN=%computername%,CN=Computers,DC=domain,DC=local" -newparent "OU=**Desktops**,OU=Computers,OU=Company,DC=domain,DC=local" )
Run Code Online (Sandbox Code Playgroud)

请问正确的命令是什么?

if-statement contains batch-file computer-name

1
推荐指数
1
解决办法
1万
查看次数

从Java中的数组中获取时出错

我写了那种代码

int[] count = new int[10];
int i = count.length;
int position = -1;
int num = kb.nextInt();

    while(i > 0)
    {
        if(count[i] == num)
        {
            position = i;
            break;
        }
         i--;
    }
Run Code Online (Sandbox Code Playgroud)

但我得到了java.lang.ArrayIndexOutOfBoundsException错误

意图是找到用户在数组中选择的最后一个数字.

java arrays indexoutofboundsexception

1
推荐指数
1
解决办法
108
查看次数

用于开发android的语言?和DVM写的?

我想学习android,以便我想了解它的背景架构.所以有谁能告诉我关于android的事情?用它开发的语言?有一篇关于android的文章,有人说在python中整个android是开发的吗?这是真的吗?JIT编译器与JAVA编译器编写的语言相同?DVM和JVM一样?或者是不同的虚拟机?Android和JAVA一样安全吗?

希望我能得到帮助,以获得前进:)感谢提前..

python java android

-1
推荐指数
1
解决办法
4870
查看次数

通过在C#中输入数据集来读取分隔的文本文件

我需要读取由enter分隔的文本文件,即每行都有一个新条目.

例如

101153,E006,"\n"  
101153,E016,"\n"  
101153,E026,"\n"  
101153,E035,"\n"  
101153,N006,"\n"  
101153,N016,2  
Run Code Online (Sandbox Code Playgroud)

我怎样才能在数据集中读取这些记录.

c# string dataset

-1
推荐指数
1
解决办法
2328
查看次数