我正在尝试在this回答的警报对话框中添加GridView。
我当前的工作提醒对话框正在使用单一选项,如下面的代码
private void showGotoPageDialog() {
if (mTotalPages > 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(
getActivity(), R.style.AlertDialogTheme);
builder.setTitle("Go to Page:");
builder.setSingleChoiceItems(mPageOptions, mPageIndx - 1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int item) {
mOptionDiag.dismiss();
mPageIndx = item + 1;
updateQuotesListServer();
updatePageInfo();
}
});
builder.setNegativeButton("Dismiss",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
}
});
mOptionDiag = builder.create();
mOptionDiag.show();
}
}
用于列表的代码如下所示
mTotalPages = (int) Math.ceil(totalQuotes / ITEMS_PER_PAGE);
mPageIndx = 1;
mPageOptions = new String[mTotalPages];
for (int i = 1; i <= mTotalPages; i++) {
mPageOptions[i - 1] = "Page " + i;
}
现在我正在这样做,以便在GridView中转换上面的对话,如下所示
private void showGotoPageDialog() {
//
// if (mTotalPages > 0) {
GridView gridView = new GridView(getActivity());
List<Integer> mList = new ArrayList<Integer>();
for (int i = 1; i<mTotalPages; i++) {
mList.add(i-1)= boolean i;
/* final int mPageOptions;
for (int i = 1; i <= mTotalPages; i++) {
mPageOptions[i - 1] = i;
}*/
}
gridView.setAdapter(new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, mList));
gridView.setNumColumns(5);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(
getActivity(), R.style.AlertDialogTheme);
builder.setTitle("Go to Page:");
builder.setView(gridView);
builder.show();
我无法在GridView对话框中为这行代码设置完美的代码。
for (int i = 1; i<mTotalPages; i++) {
mList.add(i-1)= boolean i;
如果有人可以为我建议正确的代码,请告诉我。 谢谢
答案 0 :(得分:0)
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_101'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118) ~[selenium-firefox-driver-2.33.0.jar:?]
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244) ~[selenium-firefox-driver-2.33.0.jar:?]
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110) ~[selenium-remote-driver-2.33.0.jar:?]
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:188) ~[selenium-firefox-driver-2.33.0.jar:?]
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183) ~[selenium-firefox-driver-2.33.0.jar:?]
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:100) ~[selenium-firefox-driver-2.33.0.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.FirefoxDriverConfig.createBrowser(FirefoxDriverConfig.java:41) ~[JMeterPlugins-WebDriver.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.FirefoxDriverConfig.threadStarted(FirefoxDriverConfig.java:22) ~[JMeterPlugins-WebDriver.jar:?]
at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:677) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:996) ~[jorphan%20-%20Copy.jar:3.2 r1790748]
at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:997) ~[jorphan%20-%20Copy.jar:3.2 r1790748]
at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:978) ~[jorphan%20-%20Copy.jar:3.2 r1790748]
at org.apache.jmeter.threads.JMeterThread.threadStarted(JMeterThread.java:646) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:634) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250) [ApacheJMeter_core.jar:3.2 r1790748]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
tInstallState changed: false, state: {"app-profile":{"fxdriver@googlecode.com":{"d":"C:\\Users\\Shadab_Quddus\\AppData\\Local\\Temp\\anonymous903713617974027002webdriver-profile\\extensions\\fxdriver@googlecode.com","e":false,"v":"2.33.0","st":1506749918112,"mt":1506749918081}},"app-system-defaults":{"e10srollout@mozilla.org":{"d":"C:\\Program Files\\Mozilla Firefox\\browser\\features\\e10srollout@mozilla.org.xpi","e":true,"v":"1.0","st":1462247100000},"firefox@getpocket.com":{"d":"C:\\Program Files\\Mozilla Firefox\\browser\\features\\firefox@getpocket.com.xpi","e":true,"v":"1.0","st":1462247100000},"loop@mozilla.org":{"d":"C:\\Program Files\\Mozilla Firefox\\browser\\features\\loop@mozilla.org.xpi","e":true,"v":"1.2.6","st":1462247100000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","e":true,"v":"46.0.1","st":1462247100000}}}
1506749921723 addons.xpi DEBUG No changes found